From 30301913b058df5d26ae2c0a1535f6bcdbb29933 Mon Sep 17 00:00:00 2001 From: gokulav137 Date: Tue, 12 Sep 2023 20:44:17 +0530 Subject: [PATCH] fix linting error - refactor if else chain to switch Signed-off-by: gokulav137 --- eventsources/sources/resource/start.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eventsources/sources/resource/start.go b/eventsources/sources/resource/start.go index 4ffd7287de..90a8cb9fef 100644 --- a/eventsources/sources/resource/start.go +++ b/eventsources/sources/resource/start.go @@ -251,11 +251,12 @@ func LabelReq(sel v1alpha1.Selector) (*labels.Requirement, error) { op = selection.Operator(sel.Operation) } var values []string - if (op == selection.Exists || op == selection.DoesNotExist) && sel.Value == "" { + switch { + case (op == selection.Exists || op == selection.DoesNotExist) && sel.Value == "": values = []string{} - } else if op == selection.In || op == selection.NotIn { + case op == selection.In || op == selection.NotIn: values = strings.Split(sel.Value, ",") - } else { + default: values = []string{sel.Value} } req, err := labels.NewRequirement(sel.Key, op, values)