Skip to content

Commit 50d4143

Browse files
committed
feat: add WithRequiresPruneConfirmation to sync option
Add WithRequiresPruneConfirmation so that we can pass this as an Application sync option in ArgoCD Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@ledger.fr>
1 parent 8007df5 commit 50d4143

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/sync/sync_context.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ func WithPrune(prune bool) SyncOpt {
115115
}
116116
}
117117

118+
// WithRequiresPruneConfirmation specifies if pruning resources requires a confirmation
119+
func WithRequiresPruneConfirmation(requiresConfirmation bool) SyncOpt {
120+
return func(ctx *syncContext) {
121+
ctx.requiresPruneConfirmation = requiresConfirmation
122+
}
123+
}
124+
118125
// WithPruneConfirmed specifies if prune is confirmed for resources that require confirmation
119126
func WithPruneConfirmed(confirmed bool) SyncOpt {
120127
return func(ctx *syncContext) {
@@ -367,6 +374,7 @@ type syncContext struct {
367374
pruneLast bool
368375
prunePropagationPolicy *metav1.DeletionPropagation
369376
pruneConfirmed bool
377+
requiresPruneConfirmation bool
370378
clientSideApplyMigrationManager string
371379
enableClientSideApplyMigration bool
372380

@@ -1372,7 +1380,7 @@ func (sc *syncContext) runTasks(tasks syncTasks, dryRun bool) runState {
13721380
if !sc.pruneConfirmed {
13731381
var resources []string
13741382
for _, task := range pruneTasks {
1375-
if resourceutil.HasAnnotationOption(task.liveObj, common.AnnotationSyncOptions, common.SyncOptionPruneRequireConfirm) {
1383+
if sc.requiresPruneConfirmation || resourceutil.HasAnnotationOption(task.liveObj, common.AnnotationSyncOptions, common.SyncOptionPruneRequireConfirm) {
13761384
resources = append(resources, fmt.Sprintf("%s/%s/%s", task.obj().GetAPIVersion(), task.obj().GetKind(), task.name()))
13771385
}
13781386
}

0 commit comments

Comments
 (0)