Merge pull request #133419 from Xdynix/fix-label-selector-consecutive-commas

Fix label selector parsing for consecutive commas
This commit is contained in:
Kubernetes Prow Robot
2025-08-27 17:18:41 -07:00
committed by GitHub
2 changed files with 15 additions and 1 deletions

View File

@@ -848,7 +848,6 @@ func (p *Parser) parseIdentifiersList() (sets.String, error) {
return s, nil
}
if tok2 == CommaToken {
p.consume(Values)
s.Insert("") // to handle ,, Double "" removed by StringSet
}
default: // it can be operator

View File

@@ -636,9 +636,24 @@ func TestSetSelectorParser(t *testing.T) {
{"x in (abc,)", internalSelector{
getRequirement("x", selection.In, sets.NewString("abc", ""), t),
}, true, true},
{"x in (abc,abc)", internalSelector{
getRequirement("x", selection.In, sets.NewString("abc"), t),
}, true, true},
{"x in ()", internalSelector{
getRequirement("x", selection.In, sets.NewString(""), t),
}, true, true},
{"x in (a,,)", internalSelector{
getRequirement("x", selection.In, sets.NewString("a", ""), t),
}, true, true},
{"x in (a,,,)", internalSelector{
getRequirement("x", selection.In, sets.NewString("a", ""), t),
}, true, true},
{"x in (a,,,,,,)", internalSelector{
getRequirement("x", selection.In, sets.NewString("a", ""), t),
}, true, true},
{"x in (a,,a,,a,,a,,)", internalSelector{
getRequirement("x", selection.In, sets.NewString("a", ""), t),
}, true, true},
{"x notin (abc,,def),bar,z in (),w", internalSelector{
getRequirement("bar", selection.Exists, nil, t),
getRequirement("w", selection.Exists, nil, t),