Skip to content

Commit 688e364

Browse files
committed
changed to client.DeleteAllOf
1 parent c7bd671 commit 688e364

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

controllers/hcpvaultsecretsapp_controller.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ func (r *HCPVaultSecretsAppReconciler) handleDeletion(ctx context.Context, o *se
478478
return fmt.Errorf("failed to list secrets in namespace %s: %w", o.GetNamespace(), err)
479479
}
480480
removeFinalizers(ctx, r.Client, logger, &secrets)
481+
if err := r.Client.DeleteAllOf(ctx, &secretsv1beta1.VaultDynamicSecret{},
482+
client.InNamespace(common.OperatorNamespace),
483+
client.MatchingLabels{helpers.LabelOwnerRefUID: string(o.GetUID())}); err != nil {
484+
return fmt.Errorf("failed to delete secrets in namespace %s: %w", o.GetNamespace(), err)
485+
}
481486
// then remove the finalizer from the HCPVaultSecretsApp and delete it
482487
if controllerutil.ContainsFinalizer(o, hcpVaultSecretsAppFinalizer) {
483488
logger.Info("Removing finalizer")
@@ -489,6 +494,9 @@ func (r *HCPVaultSecretsAppReconciler) handleDeletion(ctx context.Context, o *se
489494
logger.Info("Successfully removed the finalizer")
490495
}
491496
}
497+
if err := r.Delete(ctx, o); err != nil {
498+
return fmt.Errorf("failed to delete HCPVaultSecretsApp %s: %w", o.Spec.AppName, err)
499+
}
492500
return nil
493501
}
494502

0 commit comments

Comments
 (0)