@@ -57,6 +57,19 @@ type roleBase struct {
5757 status SafeStatus
5858 state SafeState
5959
60+ // Defaults, Vars and UserVars are used to store each role's variables.
61+ // Defaults are the lowest priority, Vars are the second highest, and UserVars are the highest.
62+ //
63+ // These use the gera.Map type, which is a wrapper around a map[string]string that provides hierarchical KV store
64+ // semantics.
65+ // The gera.Map logic allows us to ensure that defaults are overridden by vars, and vars by userVars throughout the
66+ // workflow tree, and at the same time that defaults/vars/userVars set in a child role override the relevant values
67+ // set in its parent role.
68+ // The way we do this is by ensuring parent-child (Wrap) relationships between all the Default members in the
69+ // workflow tree, all the Vars members, and all the UserVars members, and then whenever we need to figure out what's
70+ // the consolidated KV map seen from the point of view of a given role, we Flatten each of these three, and then
71+ // Wrap and re-Flatten between the flattened defaults, vars and userVars (see ConsolidatedVarStack). This results in
72+ // a single map, generatable from the POV of any role within the tree.
6073 Defaults * gera.WrapMap [string , string ] `yaml:"defaults,omitempty"`
6174 Vars * gera.WrapMap [string , string ] `yaml:"vars,omitempty"`
6275 UserVars * gera.WrapMap [string , string ] `yaml:"-"`
@@ -65,6 +78,8 @@ type roleBase struct {
6578 Enabled string `yaml:"enabled,omitempty"`
6679}
6780
81+ // Needed for the yaml package to correctly unmarshal into gera.Map[string, string] those Defaults and Vars entries from
82+ // a workflow template, that have a !public tag to include input widget metadata.
6883func kvStoreUnmarshalYAMLWithTags (w gera.Map [string , string ], unmarshal func (interface {}) error ) error {
6984 nodes := make (map [string ]yaml.Node )
7085 err := unmarshal (& nodes )
0 commit comments