From dd2fdd63e5c1fdaed0eb5116e32724068495fae7 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 8 Feb 2017 17:32:19 +0100 Subject: fix templater & ctx: Correctly check resource set parent --- context/context.go | 5 +++-- templater/templater.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/context/context.go b/context/context.go index 2de78541e7e6..108bda28a90d 100644 --- a/context/context.go +++ b/context/context.go @@ -17,7 +17,7 @@ type ResourceSet struct { // Fields for resource set collections Include []ResourceSet `json:"include"` - Parent *string + Parent string } type Context struct { @@ -63,6 +63,7 @@ func LoadContextFromFile(filename string) (*Context, error) { ) } + c.ResourceSets = *flattenResourceSetCollections(&c.ResourceSets) c.BaseDir = path.Dir(filename) return &c, nil @@ -79,7 +80,7 @@ func flattenResourceSetCollections(rs *[]ResourceSet) *[]ResourceSet { flattened = append(flattened, r) } else { for _, subResourceSet := range r.Include { - subResourceSet.Parent = &r.Name + subResourceSet.Parent = r.Name subResourceSet.Name = path.Join(r.Name, subResourceSet.Name) flattened = append(flattened, subResourceSet) } diff --git a/templater/templater.go b/templater/templater.go index 89d66ff38517..6ca7e6770a06 100644 --- a/templater/templater.go +++ b/templater/templater.go @@ -143,7 +143,7 @@ func applyLimits(rs *[]context.ResourceSet, include *[]string, exclude *[]string // Check whether an include/exclude string slice matches a resource set func matchesResourceSet(s *[]string, rs *context.ResourceSet) bool { for _, r := range *s { - if r == rs.Name || (rs.Parent != nil && r == *rs.Parent) { + if r == rs.Name || r == rs.Parent { return true } } -- cgit 1.4.1