-
Notifications
You must be signed in to change notification settings - Fork 748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Eventsource resourse label selector operators not working #2795
Changes from 6 commits
ccfda47
17b419e
681973d
b30df9c
3d13501
fb6c87f
e29d940
3030191
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,7 +250,14 @@ func LabelReq(sel v1alpha1.Selector) (*labels.Requirement, error) { | |
if sel.Operation != "" { | ||
op = selection.Operator(sel.Operation) | ||
} | ||
req, err := labels.NewRequirement(sel.Key, op, []string{sel.Value}) | ||
values := []string{sel.Value} | ||
if (op == selection.Exists || op == selection.DoesNotExist) && sel.Value == "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return an error when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If operator is exists or doesnotexists, an error will be thrown from labels.NewRequirement if values is not empty. Invalid value: []string{""}: values set must be empty for exists and does not exist Should I add an error from our end? @whynowy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is good, thanks! |
||
values = []string{} | ||
} | ||
if op == selection.In || op == selection.NotIn { | ||
values = strings.Split(sel.Value, ",") | ||
} | ||
req, err := labels.NewRequirement(sel.Key, op, values) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start with
var values = make([]string, 0)
, and useif
else
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense will make the change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used
switch
andvar []string
instead of if else block due to linting error.