Created
May 22, 2022 16:23
-
-
Save pivotaljohn/33cbc52e808422e68c5ec1dc2ca38354 to your computer and use it in GitHub Desktop.
Using an overlay within an overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
vlans: | |
- vlan-id: 10 | |
- vlan-id: 20 | |
- vlan-id: 30 | |
some_other_configuration: #! some other config here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@ 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