about summary refs log tree commit diff
path: root/templater
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-02-08T16·14+0100
committerVincent Ambo <tazjin@gmail.com>2017-02-08T16·34+0100
commit4e8223ef3496f390dd84a2a47fc8846afd6f7c76 (patch)
treefa64c30d2100c8b5eeece723565e9b7df3448348 /templater
parentd6b16793c150202f78e5b862b372481f08a00a6f (diff)
feat context: Add support for resource set collections
A resource set collection is a resource set with an addition 'include' array
configured. It is a short-hand for importing multiple resource sets from the
same folder and for excluding/including them as a group.

See https://github.com/tazjin/kontemplate/issues/9 for more information.

Closes #9
Diffstat (limited to 'templater')
-rw-r--r--templater/templater.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/templater/templater.go b/templater/templater.go
index bb65cd1df058..29079eb9425e 100644
--- a/templater/templater.go
+++ b/templater/templater.go
@@ -121,7 +121,7 @@ func applyLimits(rs *[]context.ResourceSet, include *[]string, exclude *[]string
 	// Exclude excluded resource sets
 	excluded := make([]context.ResourceSet, 0)
 	for _, r := range *rs {
-		if !contains(exclude, &r.Name) {
+		if !matchesResourceSet(exclude, &r) {
 			excluded = append(excluded, r)
 		}
 	}
@@ -132,7 +132,7 @@ func applyLimits(rs *[]context.ResourceSet, include *[]string, exclude *[]string
 	}
 	included := make([]context.ResourceSet, 0)
 	for _, r := range excluded {
-		if contains(include, &r.Name) {
+		if matchesResourceSet(include, &r) {
 			included = append(included, r)
 		}
 	}
@@ -140,10 +140,10 @@ func applyLimits(rs *[]context.ResourceSet, include *[]string, exclude *[]string
 	return &included
 }
 
-// Check whether a certain string is contained in a string slice
-func contains(s *[]string, v *string) bool {
+// 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 == *v {
+		if r == rs.Name || r == *rs.Parent {
 			return true
 		}
 	}