refactor: extract docker API endpoint regexp creation
This commit is contained in:
1 parent
32a12578f3
commit
633df0cdaf
1 file changed
+9
-5
+9
-5
@@ -24,16 +24,20 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
containerCreateRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/create$")
|
containerCreateRegexp = dockerAPIEndpoint("containers/create")
|
||||||
containerStartRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/[^/]*/(re)?start$")
|
containerStartRegexp = dockerAPIEndpoint("containers/[^/]*/(re)?start")
|
||||||
containerInspectRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/[^/]*/json$")
|
containerInspectRegexp = dockerAPIEndpoint("containers/[^/]*/json")
|
||||||
execCreateRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/[^/]*/exec$")
|
execCreateRegexp = dockerAPIEndpoint("containers/[^/]*/exec")
|
||||||
execInspectRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/exec/[^/]*/json$")
|
execInspectRegexp = dockerAPIEndpoint("exec/[^/]*/json")
|
||||||
|
|
||||||
ErrWeaveCIDRNone = errors.New("the container was created with the '-e WEAVE_CIDR=none' option")
|
ErrWeaveCIDRNone = errors.New("the container was created with the '-e WEAVE_CIDR=none' option")
|
||||||
ErrNoDefaultIPAM = errors.New("the container was created without specifying an IP address with '-e WEAVE_CIDR=...' and the proxy was started with the '--no-default-ipalloc' option")
|
ErrNoDefaultIPAM = errors.New("the container was created without specifying an IP address with '-e WEAVE_CIDR=...' and the proxy was started with the '--no-default-ipalloc' option")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func dockerAPIEndpoint(endpoint string) *regexp.Regexp {
|
||||||
|
return regexp.MustCompile("^(/v[0-9\\.]*)?/" + endpoint + "$")
|
||||||
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
HostnameMatch string
|
HostnameMatch string
|
||||||
HostnameReplacement string
|
HostnameReplacement string
|
||||||
|
|||||||
Reference in new issue
Block a user