Skip to content

Commit de68c32

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 89c110b commit de68c32

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) {
@@ -360,6 +367,7 @@ type syncContext struct {
360367
pruneLast bool
361368
prunePropagationPolicy *metav1.DeletionPropagation
362369
pruneConfirmed bool
370+
requiresPruneConfirmation bool
363371

364372
syncRes map[string]common.ResourceSyncResult
365373
startedAt time.Time
@@ -1270,7 +1278,7 @@ func (sc *syncContext) runTasks(tasks syncTasks, dryRun bool) runState {
12701278
if !sc.pruneConfirmed {
12711279
var resources []string
12721280
for _, task := range pruneTasks {
1273-
if resourceutil.HasAnnotationOption(task.liveObj, common.AnnotationSyncOptions, common.SyncOptionPruneRequireConfirm) {
1281+
if sc.requiresPruneConfirmation || resourceutil.HasAnnotationOption(task.liveObj, common.AnnotationSyncOptions, common.SyncOptionPruneRequireConfirm) {
12741282
resources = append(resources, fmt.Sprintf("%s/%s/%s", task.obj().GetAPIVersion(), task.obj().GetKind(), task.name()))
12751283
}
12761284
}

0 commit comments

Comments
 (0)