From 3623ede85d2ccc9849b08dec8ca2095f58a4547f Mon Sep 17 00:00:00 2001 From: Joakim Olsson Date: Wed, 1 Oct 2025 10:38:05 +0200 Subject: [PATCH] refactor: simplify namespace exclusion logic Replace the manual loop for checking excluded namespaces with the built-in slices.Contains function. This change enhances the readability and efficiency of the code, while also allowing for wildcard matching in exclusion. --- main.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index dab7cfa..092fbeb 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "context" "flag" "log" + "slices" "strings" "time" @@ -91,12 +92,7 @@ func main() { } func nsExcluded(name string, excludedNS []string) bool { - for _, ns := range excludedNS { - if name == ns { - return true - } - } - return false + return slices.Contains(excludedNS, name) || slices.Contains(excludedNS, "*") } func parseArgs() args {