@@ -129,6 +129,13 @@ func WithPruneConfirmed(confirmed bool) SyncOpt {
129
129
}
130
130
}
131
131
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
+
132
139
// WithOperationSettings allows to set sync operation settings
133
140
func WithOperationSettings (dryRun bool , prune bool , force bool , skipHooks bool ) SyncOpt {
134
141
return func (ctx * syncContext ) {
@@ -368,6 +375,7 @@ type syncContext struct {
368
375
prunePropagationPolicy * metav1.DeletionPropagation
369
376
pruneConfirmed bool
370
377
requiresPruneConfirmation bool
378
+ pruneDisabled bool
371
379
372
380
syncRes map [string ]common.ResourceSyncResult
373
381
startedAt time.Time
@@ -1122,7 +1130,7 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
1122
1130
func (sc * syncContext ) pruneObject (liveObj * unstructured.Unstructured , prune , dryRun bool ) (common.ResultCode , string ) {
1123
1131
if ! prune {
1124
1132
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 {
1126
1134
return common .ResultCodePruneSkipped , "ignored (no prune)"
1127
1135
}
1128
1136
if dryRun {
0 commit comments