mirror of https://github.com/docker/docs.git
cleanup and add comments
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
This commit is contained in:
parent
564cca1a22
commit
790b1ea45d
|
@ -41,21 +41,21 @@ func (f *ConstraintFilter) match(pattern, s string, useRegex bool) bool {
|
||||||
func (f *ConstraintFilter) Filter(config *dockerclient.ContainerConfig, nodes []*cluster.Node) ([]*cluster.Node, error) {
|
func (f *ConstraintFilter) Filter(config *dockerclient.ContainerConfig, nodes []*cluster.Node) ([]*cluster.Node, error) {
|
||||||
constraints := extractEnv("constraint", config.Env)
|
constraints := extractEnv("constraint", config.Env)
|
||||||
for k, v := range constraints {
|
for k, v := range constraints {
|
||||||
|
|
||||||
v0 := v
|
|
||||||
|
|
||||||
log.Debugf("matching constraint: %s=%s", k, v)
|
log.Debugf("matching constraint: %s=%s", k, v)
|
||||||
|
|
||||||
negate := false
|
// keep the original for display in case of error
|
||||||
useRegex := false
|
v0 := v
|
||||||
|
|
||||||
|
negate := false
|
||||||
if strings.HasPrefix(v, "!") {
|
if strings.HasPrefix(v, "!") {
|
||||||
log.Debugf("negate detected")
|
log.Debugf("negate detected")
|
||||||
v = strings.TrimPrefix(v, "!")
|
v = strings.TrimPrefix(v, "!")
|
||||||
negate = true
|
negate = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useRegex := false
|
||||||
if strings.HasPrefix(v, "/") && strings.HasSuffix(v, "/") {
|
if strings.HasPrefix(v, "/") && strings.HasSuffix(v, "/") {
|
||||||
log.Infof("regex detected")
|
log.Debugf("regex detected")
|
||||||
v = strings.TrimPrefix(strings.TrimSuffix(v, "/"), "/")
|
v = strings.TrimPrefix(strings.TrimSuffix(v, "/"), "/")
|
||||||
useRegex = true
|
useRegex = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue