mirror of https://github.com/docker/cli.git
cli-plugins/manager: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
7fde1f799f
commit
1ed3859879
|
@ -8,14 +8,14 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/cli/cli-plugins/metadata"
|
"github.com/docker/cli/cli-plugins/metadata"
|
||||||
|
"github.com/docker/cli/internal/lazyregexp"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pluginNameRe = regexp.MustCompile("^[a-z][a-z0-9]*$")
|
var pluginNameRe = lazyregexp.New("^[a-z][a-z0-9]*$")
|
||||||
|
|
||||||
// Plugin represents a potential plugin with all it's metadata.
|
// Plugin represents a potential plugin with all it's metadata.
|
||||||
type Plugin struct {
|
type Plugin struct {
|
||||||
|
|
|
@ -75,6 +75,10 @@ func (r *Regexp) ReplaceAllLiteralString(src, repl string) string {
|
||||||
return r.re().ReplaceAllLiteralString(src, repl)
|
return r.re().ReplaceAllLiteralString(src, repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Regexp) String() string {
|
||||||
|
return r.re().String()
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Regexp) SubexpNames() []string {
|
func (r *Regexp) SubexpNames() []string {
|
||||||
return r.re().SubexpNames()
|
return r.re().SubexpNames()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue