expr: Get rid of MatchEmpty.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2015-01-28 12:12:09 -08:00
parent fc192b7077
commit 04fc1ab997
2 changed files with 7 additions and 6 deletions

View File

@ -34,11 +34,16 @@ func (f *ConstraintFilter) Filter(config *dockerclient.ContainerConfig, nodes []
if constraint.Match(label) {
candidates = append(candidates, node)
}
} else if constraint.MatchEmpty() {
} else {
// The node doesn't have this particular label.
if constraint.operator == NOTEQ {
// Special case: If the operator is != and the node doesn't
// have the label at all, consider it as a candidate.
candidates = append(candidates, node)
}
}
}
}
if len(candidates) == 0 {
return nil, fmt.Errorf("unable to find a node that satisfies %s%s%s", constraint.key, OPERATORS[constraint.operator], constraint.value)
}

View File

@ -72,10 +72,6 @@ func parseExprs(key string, env []string) ([]expr, error) {
return exprs, nil
}
func (e *expr) MatchEmpty() bool {
return e.operator == NOTEQ
}
func (e *expr) Match(whats ...string) bool {
var (
pattern string