Skip to content

Instantly share code, notes, and snippets.

@AndreSteenveld
Last active August 26, 2020 20:31
Show Gist options
  • Save AndreSteenveld/b4e25ad09653d3866ed3524718684134 to your computer and use it in GitHub Desktop.
Save AndreSteenveld/b4e25ad09653d3866ed3524718684134 to your computer and use it in GitHub Desktop.
How would I do a mixin?
version: "3.7"
services:
cool-container:
beverages:
- Mate
- Coffee
- Tea
- Water
labels:
- cold
- ice
- snow
hot-container:
beverages:
- Coffee
- Tea
- Water
labels:
- warm
- lava
- fire
version: '3.7'
---
#@ def beverages( ):
#@overlay/merge
beverages:
- Coffee
- Tea
- Water
#@ end
---
#@ load( "@ytt:overlay", "overlay" )
#@overlay/match by=overlay.all
#@overlay/match-child-defaults missing_ok=True
---
#@overlay/assert
version: '3.7'
services:
cool-container:
#! How do I overlay the fragment from beverages here? The following don't really work:
#! #@ overlay.apply( beverages( ) ), this just seems to do nothing
#! _: #@ template.replace( beverages( ) ), correctly throws an error about a duplicate key
#!
#! I've looked in the documentation and the tickets I could find but couldn't find anything
#! like overlay.insert( ... ), overlay.mixin( ... ) etc.
beverages:
- Mate
labels:
- "cold"
- "ice"
- "snow"
---
#@ load( "@ytt:overlay", "overlay" )
#@ load( "@ytt:template", "template" )
#@overlay/match by=overlay.all
#@overlay/match-child-defaults missing_ok=True
---
#@overlay/assert
version: '3.7'
services:
hot-container:
_: #@ template.replace( beverages( ) )
labels:
- "warm"
- "lava"
- "fire"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment