diff --git a/pkg/filters/options.go b/pkg/filters/options.go index 0244b0f1..1ec13a00 100644 --- a/pkg/filters/options.go +++ b/pkg/filters/options.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "os" + "slices" "strings" "sync" "time" @@ -120,6 +121,8 @@ func (o *Options) Namespaces(clientset kubernetes.Interface) []string { excludeNamespaces := o.ExcludeNamespaces if len(o.IncludeNamespaces) > 0 { + slices.Sort(includeNamespaces) + includeNamespaces = slices.Compact(includeNamespaces) for _, ns := range includeNamespaces { @@ -137,10 +140,6 @@ func (o *Options) Namespaces(clientset kubernetes.Interface) []string { return } - for _, ns := range namespaceList.Items { - namespacesMap[ns.Name] = false - } - for _, ns := range namespaceList.Items { namespacesMap[ns.Name] = true }