Skip to content

Commit 1460b8a

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 69dfa70 commit 1460b8a

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) {
@@ -374,6 +381,7 @@ type syncContext struct {
374381
pruneLast bool
375382
prunePropagationPolicy *metav1.DeletionPropagation
376383
pruneConfirmed bool
384+
requiresPruneConfirmation bool
377385
clientSideApplyMigrationManager string
378386
enableClientSideApplyMigration bool
379387

@@ -1360,7 +1368,7 @@ func (sc *syncContext) runTasks(tasks syncTasks, dryRun bool) runState {
13601368
if !sc.pruneConfirmed {
13611369
var resources []string
13621370
for _, task := range pruneTasks {
1363-
if resourceutil.HasAnnotationOption(task.liveObj, common.AnnotationSyncOptions, common.SyncOptionPruneRequireConfirm) {
1371+
if sc.requiresPruneConfirmation || resourceutil.HasAnnotationOption(task.liveObj, common.AnnotationSyncOptions, common.SyncOptionPruneRequireConfirm) {
13641372
resources = append(resources, fmt.Sprintf("%s/%s/%s", task.obj().GetAPIVersion(), task.obj().GetKind(), task.name()))
13651373
}
13661374
}

0 commit comments

Comments
 (0)