Skip to content

Commit

Permalink
Use build in 'contains'
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianmoisey committed Jun 7, 2024
1 parent 4073194 commit af33e13
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package input
import (
"context"
"fmt"
"slices"
"time"

apiv1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -315,15 +316,6 @@ func selectsRecommender(selectors []*vpa_types.VerticalPodAutoscalerRecommenderS
return false
}

func selectsNamespace(namespace string, names []string) bool {
for _, n := range names {
if namespace == n {
return true
}
}
return false
}

// Filter VPA objects whose specified recommender names are not default
func filterVPAs(feeder *clusterStateFeeder, allVpaCRDs []*vpa_types.VerticalPodAutoscaler) []*vpa_types.VerticalPodAutoscaler {
klog.V(3).Infof("Start selecting the vpaCRDs.")
Expand All @@ -345,7 +337,7 @@ func filterVPAs(feeder *clusterStateFeeder, allVpaCRDs []*vpa_types.VerticalPodA
}
}

if selectsNamespace(vpaCRD.ObjectMeta.Namespace, feeder.ignoredNamespaces) {
if slices.Contains(feeder.ignoredNamespaces, vpaCRD.ObjectMeta.Namespace) {
klog.V(6).Infof("Ignoring vpaCRD %s in namespace %s as namespace is ignored", vpaCRD.Name, vpaCRD.Namespace)
continue
}
Expand Down

0 comments on commit af33e13

Please sign in to comment.