Skip to content

Commit d9429e6

Browse files
committed
feat: add WithRequiresPruneConfirmation to syncoption
Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@ledger.fr>
1 parent de68c32 commit d9429e6

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
@@ -129,6 +129,13 @@ func WithPruneConfirmed(confirmed bool) SyncOpt {
129129
}
130130
}
131131

132+
// WithPruneDisabled specifies if prune is globally disabled for this application
133+
func WithPruneDisabled(confirmed bool) SyncOpt {
134+
return func(ctx *syncContext) {
135+
ctx.pruneConfirmed = confirmed
136+
}
137+
}
138+
132139
// WithOperationSettings allows to set sync operation settings
133140
func WithOperationSettings(dryRun bool, prune bool, force bool, skipHooks bool) SyncOpt {
134141
return func(ctx *syncContext) {
@@ -368,6 +375,7 @@ type syncContext struct {
368375
prunePropagationPolicy *metav1.DeletionPropagation
369376
pruneConfirmed bool
370377
requiresPruneConfirmation bool
378+
pruneDisabled bool
371379

372380
syncRes map[string]common.ResourceSyncResult
373381
startedAt time.Time
@@ -1122,7 +1130,7 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
11221130
func (sc *syncContext) pruneObject(liveObj *unstructured.Unstructured, prune, dryRun bool) (common.ResultCode, string) {
11231131
if !prune {
11241132
return common.ResultCodePruneSkipped, "ignored (requires pruning)"
1125-
} else if resourceutil.HasAnnotationOption(liveObj, common.AnnotationSyncOptions, common.SyncOptionDisablePrune) {
1133+
} else if resourceutil.HasAnnotationOption(liveObj, common.AnnotationSyncOptions, common.SyncOptionDisablePrune) || sc.pruneDisabled {
11261134
return common.ResultCodePruneSkipped, "ignored (no prune)"
11271135
}
11281136
if dryRun {

0 commit comments

Comments
 (0)