YAML Anchors and References
This is a post to help me remind how YAML Anchors and References work.
What?
In YAML you can make an Anchor:
- first_name: &me Robert
Now the Anchor me
contains Robert
. To refer to it, do something like this:
- first_name: &me Robert
give_name: *me
The value for given_name
has been set to Robert
.
You can also anchor to a whole list item:
people:
- person: &me
name: Robert
family_name: de Bock
No you may refer to the me
anchor:
access:
- person: *me
Now Robert
has access
.
Good to prevent dry.