@@ -116,6 +116,13 @@ func WithPrune(prune bool) SyncOpt {
116116 }
117117}
118118
119+ // WithPruneConfirmed specifies if prune is confirmed for resources that require confirmation
120+ func WithPruneConfirmed (confirmed bool ) SyncOpt {
121+ return func (ctx * syncContext ) {
122+ ctx .pruneConfirmed = confirmed
123+ }
124+ }
125+
119126// WithOperationSettings allows to set sync operation settings
120127func WithOperationSettings (dryRun bool , prune bool , force bool , skipHooks bool ) SyncOpt {
121128 return func (ctx * syncContext ) {
@@ -339,6 +346,7 @@ type syncContext struct {
339346 serverSideApplyManager string
340347 pruneLast bool
341348 prunePropagationPolicy * metav1.DeletionPropagation
349+ pruneConfirmed bool
342350
343351 syncRes map [string ]common.ResourceSyncResult
344352 startedAt time.Time
@@ -1149,6 +1157,24 @@ func (sc *syncContext) runTasks(tasks syncTasks, dryRun bool) runState {
11491157 }
11501158 // prune first
11511159 {
1160+ if ! sc .pruneConfirmed {
1161+ var resources []string
1162+ for _ , task := range pruneTasks {
1163+ if resourceutil .HasAnnotationOption (task .liveObj , common .AnnotationSyncOptions , common .SyncOptionPruneRequireConfirm ) {
1164+ resources = append (resources , fmt .Sprintf ("%s/%s/%s" , task .obj ().GetAPIVersion (), task .obj ().GetKind (), task .name ()))
1165+ }
1166+ }
1167+ if len (resources ) > 0 {
1168+ sc .log .WithValues ("resources" , resources ).Info ("Prune requires confirmation" )
1169+ andMessage := ""
1170+ if len (resources ) > 1 {
1171+ andMessage = fmt .Sprintf (" and %d more resources" , len (resources )- 1 )
1172+ }
1173+ sc .message = fmt .Sprintf ("Waiting for pruning confirmation of %s%s" , resources [0 ], andMessage )
1174+ return pending
1175+ }
1176+ }
1177+
11521178 ss := newStateSync (state )
11531179 for _ , task := range pruneTasks {
11541180 t := task
0 commit comments