Skip to content

Commit

Permalink
changed to client.DeleteAllOf
Browse files Browse the repository at this point in the history
  • Loading branch information
jaireddjawed committed Feb 12, 2025
1 parent c7bd671 commit 688e364
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controllers/hcpvaultsecretsapp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ func (r *HCPVaultSecretsAppReconciler) handleDeletion(ctx context.Context, o *se
return fmt.Errorf("failed to list secrets in namespace %s: %w", o.GetNamespace(), err)
}
removeFinalizers(ctx, r.Client, logger, &secrets)
if err := r.Client.DeleteAllOf(ctx, &secretsv1beta1.VaultDynamicSecret{},
client.InNamespace(common.OperatorNamespace),
client.MatchingLabels{helpers.LabelOwnerRefUID: string(o.GetUID())}); err != nil {
return fmt.Errorf("failed to delete secrets in namespace %s: %w", o.GetNamespace(), err)
}
// then remove the finalizer from the HCPVaultSecretsApp and delete it
if controllerutil.ContainsFinalizer(o, hcpVaultSecretsAppFinalizer) {
logger.Info("Removing finalizer")
Expand All @@ -489,6 +494,9 @@ func (r *HCPVaultSecretsAppReconciler) handleDeletion(ctx context.Context, o *se
logger.Info("Successfully removed the finalizer")
}
}
if err := r.Delete(ctx, o); err != nil {
return fmt.Errorf("failed to delete HCPVaultSecretsApp %s: %w", o.Spec.AppName, err)
}
return nil
}

Expand Down

0 comments on commit 688e364

Please sign in to comment.