@@ -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 (disabled bool ) SyncOpt {
134
+ return func (ctx * syncContext ) {
135
+ ctx .pruneDisabled = disabled
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 ) {
@@ -375,6 +382,7 @@ type syncContext struct {
375
382
prunePropagationPolicy * metav1.DeletionPropagation
376
383
pruneConfirmed bool
377
384
requiresPruneConfirmation bool
385
+ pruneDisabled bool
378
386
clientSideApplyMigrationManager string
379
387
enableClientSideApplyMigration bool
380
388
@@ -1220,7 +1228,7 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
1220
1228
func (sc * syncContext ) pruneObject (liveObj * unstructured.Unstructured , prune , dryRun bool ) (common.ResultCode , string ) {
1221
1229
if ! prune {
1222
1230
return common .ResultCodePruneSkipped , "ignored (requires pruning)"
1223
- } else if resourceutil .HasAnnotationOption (liveObj , common .AnnotationSyncOptions , common .SyncOptionDisablePrune ) {
1231
+ } else if resourceutil .HasAnnotationOption (liveObj , common .AnnotationSyncOptions , common .SyncOptionDisablePrune ) || sc . pruneDisabled {
1224
1232
return common .ResultCodePruneSkipped , "ignored (no prune)"
1225
1233
}
1226
1234
if dryRun {
0 commit comments