@@ -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 ) {
@@ -382,6 +389,7 @@ type syncContext struct {
382
389
prunePropagationPolicy * metav1.DeletionPropagation
383
390
pruneConfirmed bool
384
391
requiresPruneConfirmation bool
392
+ pruneDisabled bool
385
393
clientSideApplyMigrationManager string
386
394
enableClientSideApplyMigration bool
387
395
@@ -1208,7 +1216,7 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
1208
1216
func (sc * syncContext ) pruneObject (liveObj * unstructured.Unstructured , prune , dryRun bool ) (common.ResultCode , string ) {
1209
1217
if ! prune {
1210
1218
return common .ResultCodePruneSkipped , "ignored (requires pruning)"
1211
- } else if resourceutil .HasAnnotationOption (liveObj , common .AnnotationSyncOptions , common .SyncOptionDisablePrune ) {
1219
+ } else if resourceutil .HasAnnotationOption (liveObj , common .AnnotationSyncOptions , common .SyncOptionDisablePrune ) || sc . pruneDisabled {
1212
1220
return common .ResultCodePruneSkipped , "ignored (no prune)"
1213
1221
}
1214
1222
if dryRun {
0 commit comments