about summary refs log tree commit diff
path: root/context/context.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-08-25T12·35+0200
committerVincent Ambo <tazjin@gmail.com>2017-08-25T12·44+0200
commit063a3e9d3037c77aea765d7c58bff567b21d5946 (patch)
tree3dd021b9eb1a3bc83f21a930de2c58e4b1e94e1f /context/context.go
parent8ccaab322a93af0ea81ae4d2c564f550b5c3964d (diff)
fix context: Support ".yml" extension on default files
In other places in Kontemplate that deal with YAML files, both the
".yaml" and ".yml" extension are supported.

This fixes context loading code to support that for resource set
variables, too.

This fixes #83
Diffstat (limited to 'context/context.go')
-rw-r--r--context/context.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/context/context.go b/context/context.go
index 0e787b559996..fe04a051efed 100644
--- a/context/context.go
+++ b/context/context.go
@@ -143,16 +143,13 @@ func loadAllDefaultValues(c *Context) []ResourceSet {
 func loadDefaultValues(rs *ResourceSet, c *Context) *map[string]interface{} {
 	var defaultVars map[string]interface{}
 
-	// Attempt to load YAML values
-	err := util.LoadJsonOrYaml(path.Join(c.BaseDir, rs.Path, "default.yaml"), &defaultVars)
-	if err == nil {
-		return util.Merge(&defaultVars, &rs.Values)
-	}
+	defaultFilenames := []string{"default.yml", "default.yaml", "default.json"}
 
-	// Attempt to load JSON values
-	err = util.LoadJsonOrYaml(path.Join(c.BaseDir, rs.Path, "default.json"), &defaultVars)
-	if err == nil {
-		return util.Merge(&defaultVars, &rs.Values)
+	for _, filename := range defaultFilenames {
+		err := util.LoadJsonOrYaml(path.Join(c.BaseDir, rs.Path, filename), &defaultVars)
+		if err == nil {
+			return util.Merge(&defaultVars, &rs.Values)
+		}
 	}
 
 	// The actual error is not inspected here. The reasoning for this is that in case of serious problems (e.g.