Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Patryk Małek <patryk.malek@konghq.com>
  • Loading branch information
czeslavo and pmalek authored Aug 7, 2024
1 parent 8baa7e5 commit c6dcbd5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/utils/kubernetes/reduce/reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,16 @@ func ReduceHPAs(ctx context.Context, k8sClient client.Client, hpas []autoscaling
return nil
}

// +kubebuilder:rbac:groups=policy,resources=poddistruptionbudgets,verbs=delete
// +kubebuilder:rbac:groups=policy,resources=poddisruptionbudgets,verbs=delete

// PDBFilterFunc filters a list of PodDisruptionBudgets.
type PDBFilterFunc func(hpas []policyv1.PodDisruptionBudget) []policyv1.PodDisruptionBudget

// ReducePodDisruptionBudgets detects the best PodDisruptionBudget in the set and deletes all the others.
func ReducePodDisruptionBudgets(ctx context.Context, k8sClient client.Client, pdbs []policyv1.PodDisruptionBudget, filter PDBFilterFunc) error {
for _, hpa := range filter(pdbs) {
hpa := hpa
if err := k8sClient.Delete(ctx, &hpa); client.IgnoreNotFound(err) != nil {
for _, pdb := range filter(pdbs) {
pdb := pdb
if err := k8sClient.Delete(ctx, &pdb); client.IgnoreNotFound(err) != nil {
return err
}
}
Expand Down

0 comments on commit c6dcbd5

Please sign in to comment.