Address comments; fix incorrect hash

This commit is contained in:
Janet Kuo
2016-02-19 10:25:34 -08:00
parent 0e5da8460d
commit dc78af948e
2 changed files with 41 additions and 41 deletions

View File

@@ -120,16 +120,7 @@ func AddLabelToSelector(selector *unversioned.LabelSelector, labelKey string, la
return selector
}
// SelectorHasLabel checks if the given selector contains the given label key in its MatchLabels or MatchExpressions
// SelectorHasLabel checks if the given selector contains the given label key in its MatchLabels
func SelectorHasLabel(selector *unversioned.LabelSelector, labelKey string) bool {
_, found := selector.MatchLabels[labelKey]
if found {
return true
}
for _, exp := range selector.MatchExpressions {
if exp.Key == labelKey && exp.Operator != unversioned.LabelSelectorOpDoesNotExist {
return true
}
}
return false
return len(selector.MatchLabels[labelKey]) > 0
}