Commit ee94968f authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #39260 from tanshanshan/check-empty-set

Automatic merge from submit-queue check if the set is empty , and delete the reduntant type convert. **What this PR does / why we need it**: check if the set is empty , and delete the reduntant type convert. Thanks. **Special notes for your reviewer**: **Release note**: ```release-note ```
parents 089d6e26 702fe312
...@@ -793,7 +793,7 @@ func validateLabelValue(v string) error { ...@@ -793,7 +793,7 @@ func validateLabelValue(v string) error {
// SelectorFromSet returns a Selector which will match exactly the given Set. A // SelectorFromSet returns a Selector which will match exactly the given Set. A
// nil and empty Sets are considered equivalent to Everything(). // nil and empty Sets are considered equivalent to Everything().
func SelectorFromSet(ls Set) Selector { func SelectorFromSet(ls Set) Selector {
if ls == nil { if ls == nil || len(ls) == 0 {
return internalSelector{} return internalSelector{}
} }
var requirements internalSelector var requirements internalSelector
...@@ -807,14 +807,14 @@ func SelectorFromSet(ls Set) Selector { ...@@ -807,14 +807,14 @@ func SelectorFromSet(ls Set) Selector {
} }
// sort to have deterministic string representation // sort to have deterministic string representation
sort.Sort(ByKey(requirements)) sort.Sort(ByKey(requirements))
return internalSelector(requirements) return requirements
} }
// SelectorFromValidatedSet returns a Selector which will match exactly the given Set. // SelectorFromValidatedSet returns a Selector which will match exactly the given Set.
// A nil and empty Sets are considered equivalent to Everything(). // A nil and empty Sets are considered equivalent to Everything().
// It assumes that Set is already validated and doesn't do any validation. // It assumes that Set is already validated and doesn't do any validation.
func SelectorFromValidatedSet(ls Set) Selector { func SelectorFromValidatedSet(ls Set) Selector {
if ls == nil { if ls == nil || len(ls) == 0 {
return internalSelector{} return internalSelector{}
} }
var requirements internalSelector var requirements internalSelector
...@@ -823,7 +823,7 @@ func SelectorFromValidatedSet(ls Set) Selector { ...@@ -823,7 +823,7 @@ func SelectorFromValidatedSet(ls Set) Selector {
} }
// sort to have deterministic string representation // sort to have deterministic string representation
sort.Sort(ByKey(requirements)) sort.Sort(ByKey(requirements))
return internalSelector(requirements) return requirements
} }
// ParseToRequirements takes a string representing a selector and returns a list of // ParseToRequirements takes a string representing a selector and returns a list of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment