-
Notifications
You must be signed in to change notification settings - Fork 738
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
fix: Eventsource resourse label selector operators not working #2795
Conversation
feat: add all sprig functions to templates (argoproj#2768)
…r correctly - For Exists and DoesNotExists value is set to empty if no value is provided when creating label requirement - For In and NotIn value is split by "," to create label requirement Signed-off-by: gokulav137 <gokulav999@gmail.com>
- Test equality operators =, == and in - Test inequality operators != and notin - Test greater than operator and lower than operator - Test exists operator and doesnot exist operator - Test comma separated values for in - Test invalid operators <= and >= Signed-off-by: gokulav137 <gokulav999@gmail.com>
Signed-off-by: gokulav137 <gokulav999@gmail.com>
Signed-off-by: gokulav137 <gokulav999@gmail.com>
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Return an error when sel.Value != ""
?
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
This is good, thanks!
@@ -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} |
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 use if
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
and var []string
instead of if else block due to linting error.
Signed-off-by: gokulav137 <gokulav999@gmail.com>
Signed-off-by: gokulav137 <gokulav999@gmail.com>
7b256a7
to
3030191
Compare
…roj#2795) Signed-off-by: gokulav137 <gokulav999@gmail.com> Signed-off-by: jmillage <jmillage@bcubed-corp.com>
Fixes : #2775
Fixed Exist and DoesNotExist throwing error
2023-08-26T14:33:06.147Z ERROR argo-events.eventsource eventsources/eventing.go:564 Failed to start listening eventsource {"eventSourceName": "notification", "eventSourceType": "resource", "eventName": "completed-workflows", "error": "failed after retries: failed to create the label selector for the event source completed-workflows, values: Invalid value: []string{\"\"}: values set must be empty for exists and does not exist"}
Fixed documentation mentioning unsupported operators
Add multiple value support for In and NotIn using comma seperator
Checklist: