Skip to content

Instantly share code, notes, and snippets.

@pivotaljohn
Created May 22, 2022 16:23
Show Gist options
  • Save pivotaljohn/33cbc52e808422e68c5ec1dc2ca38354 to your computer and use it in GitHub Desktop.
Save pivotaljohn/33cbc52e808422e68c5ec1dc2ca38354 to your computer and use it in GitHub Desktop.
Using an overlay within an overlay
---
vlans:
- vlan-id: 10
- vlan-id: 20
- vlan-id: 30
some_other_configuration: #! some other config here
#@ load("@ytt:overlay", "overlay")
#@ def with_name(vlan):
#@overlay/match missing_ok=True
vlan-name: #@ "vlan{}".format(vlan["vlan-id"])
#@ end
#@overlay/match by=overlay.all
---
vlans:
#@overlay/match by=lambda idx, left, right: "vlan-id" in left, expects="1+"
#@overlay/replace via=lambda left, right: overlay.apply(left, with_name(left))
-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment