Skip to content

Instantly share code, notes, and snippets.

@pivotaljohn
Last active April 19, 2023 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pivotaljohn/9b18f45765efc0b6d5460a4b2c6bfdd7 to your computer and use it in GitHub Desktop.
Save pivotaljohn/9b18f45765efc0b6d5460a4b2c6bfdd7 to your computer and use it in GitHub Desktop.
kind: Widget
metadata:
name: foo-with-more-than-all-labels
labels:
label0: value0
label1: value1
label2: value2
label3: value3
label4: value4
---
kind: Widget
metadata:
name: foo-with-all-labels
labels:
label1: value1
label2: value2
label3: value3
---
kind: Widget
metadata:
name: foo-with-some-labels
labels:
label2: value2
label3: value3
---
kind: Widget
metadata:
name: foo-with-none-of-labels
labels:
labelX: valueX
labelY: valueY
---
kind: Widget
metadata:
name: foo-without-labels
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.all, expects="1+"
---
#@overlay/match-child-defaults when=1
metadata:
labels:
#@overlay/remove
label1:
#@overlay/remove
label2:
#@overlay/remove
label3:
#! If "labels" is now empty, remove it entirely
#@overlay/match by=overlay.all, expects="1+"
---
metadata:
#@overlay/match by=lambda _, left, __: len(left) == 0, when=1
#@overlay/remove
labels:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment