@@ -299,6 +299,13 @@ func PatchWorkload(workload *v1.Resource, patcher *v1.Patcher) error {
299
299
}
300
300
// merge labels
301
301
for k , v := range patcher .Labels {
302
+ // NOTE: we implement value-based map removal by agreeing on a specific value
303
+ // `ops://kusionstack.io/remove` as the `remove` operation index for label patcher.
304
+ if v == removalVal {
305
+ delete (objLabels , k )
306
+ continue
307
+ }
308
+
302
309
objLabels [k ] = v
303
310
}
304
311
un .SetLabels (objLabels )
@@ -315,6 +322,13 @@ func PatchWorkload(workload *v1.Resource, patcher *v1.Patcher) error {
315
322
}
316
323
// merge labels
317
324
for k , v := range patcher .PodLabels {
325
+ // NOTE: we implement value-based map removal by agreeing on a specific value
326
+ // `ops://kusionstack.io/remove` as the `remove` operation index for pod label patcher.
327
+ if v == removalVal {
328
+ delete (podLabels , k )
329
+ continue
330
+ }
331
+
318
332
podLabels [k ] = v
319
333
}
320
334
err = unstructured .SetNestedStringMap (un .Object , podLabels , "spec" , "template" , "metadata" , "labels" )
@@ -331,6 +345,13 @@ func PatchWorkload(workload *v1.Resource, patcher *v1.Patcher) error {
331
345
}
332
346
// merge annotations
333
347
for k , v := range patcher .Annotations {
348
+ // NOTE: we implement value-based map removal by agreeing on a specific value
349
+ // `ops://kusionstack.io/remove` as the `remove` operation index for annotation patcher.
350
+ if v == removalVal {
351
+ delete (objAnnotations , k )
352
+ continue
353
+ }
354
+
334
355
objAnnotations [k ] = v
335
356
}
336
357
un .SetAnnotations (objAnnotations )
@@ -347,6 +368,13 @@ func PatchWorkload(workload *v1.Resource, patcher *v1.Patcher) error {
347
368
}
348
369
// merge annotations
349
370
for k , v := range patcher .PodAnnotations {
371
+ // NOTE: we implement value-based map removal by agreeing on a specific value
372
+ // `ops://kusionstack.io/remove` as the `remove` operation index for pod annotation patcher.
373
+ if v == removalVal {
374
+ delete (podAnnotations , k )
375
+ continue
376
+ }
377
+
350
378
podAnnotations [k ] = v
351
379
}
352
380
err = unstructured .SetNestedStringMap (un .Object , podAnnotations , "spec" , "template" , "metadata" , "annotations" )
0 commit comments