about summary refs log tree commit diff
path: root/context/context.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-02-14T18·00+0100
committerVincent Ambo <tazjin@gmail.com>2017-02-14T18·12+0100
commit0147c3e13e741f1d2bac7f082e509222fb86ab38 (patch)
tree2dccf2eb214b2c20ab4527e386e4459c7735022c /context/context.go
parentf81fe551bcf1baa1167ed237c7120df69cf2ddab (diff)
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
Diffstat (limited to 'context/context.go')
-rw-r--r--context/context.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/context/context.go b/context/context.go
index 108bda28a90d..520070d88f67 100644
--- a/context/context.go
+++ b/context/context.go
@@ -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)
 			}
 		}