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) {
|
||||
constraints := extractEnv("constraint", config.Env)
|
||||
for k, v := range constraints {
|
||||
|
||||
v0 := v
|
||||
|
||||
log.Debugf("matching constraint: %s=%s", k, v)
|
||||
|
||||
negate := false
|
||||
useRegex := false
|
||||
// keep the original for display in case of error
|
||||
v0 := v
|
||||
|
||||
negate := false
|
||||
if strings.HasPrefix(v, "!") {
|
||||
log.Debugf("negate detected")
|
||||
v = strings.TrimPrefix(v, "!")
|
||||
negate = true
|
||||
}
|
||||
|
||||
useRegex := false
|
||||
if strings.HasPrefix(v, "/") && strings.HasSuffix(v, "/") {
|
||||
log.Infof("regex detected")
|
||||
log.Debugf("regex detected")
|
||||
v = strings.TrimPrefix(strings.TrimSuffix(v, "/"), "/")
|
||||
useRegex = true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue