mirror of https://github.com/docker/docs.git
expr: Get rid of MatchEmpty.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
fc192b7077
commit
04fc1ab997
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue