feat ctx: Let sub-resource-sets inherit vars from parent
Users of kontemplate may expect variables defined on the parent resource to be inherited by children. This implements that functionality. Values defined twice are overwritten by the child's definition. Fixes #20
This commit is contained in:
parent
f81fe551bc
commit
0147c3e13e
4 changed files with 81 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/polydawn/meep"
|
||||
"github.com/tazjin/kontemplate/util"
|
||||
)
|
||||
|
||||
type ResourceSet struct {
|
||||
|
|
@ -82,6 +83,7 @@ func flattenResourceSetCollections(rs *[]ResourceSet) *[]ResourceSet {
|
|||
for _, subResourceSet := range r.Include {
|
||||
subResourceSet.Parent = r.Name
|
||||
subResourceSet.Name = path.Join(r.Name, subResourceSet.Name)
|
||||
subResourceSet.Values = *util.Merge(&r.Values, &subResourceSet.Values)
|
||||
flattened = append(flattened, subResourceSet)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue