about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--main.go4
-rw-r--r--util/util.go17
2 files changed, 8 insertions, 13 deletions
diff --git a/main.go b/main.go
index b792a1a3b517..0ca8de428e6c 100644
--- a/main.go
+++ b/main.go
@@ -35,8 +35,8 @@ var (
 	app = kingpin.New("kontemplate", "simple Kubernetes resource templating")
 
 	// Global flags
-	includes = app.Flag("include", "Resource sets to include explicitly").Short('i').Strings()
-	excludes = app.Flag("exclude", "Resource sets to exclude explicitly").Short('e').Strings()
+	includes  = app.Flag("include", "Resource sets to include explicitly").Short('i').Strings()
+	excludes  = app.Flag("exclude", "Resource sets to exclude explicitly").Short('e').Strings()
 	variables = app.Flag("var", "Provide variables to templates explicitly").Strings()
 
 	// Commands
diff --git a/util/util.go b/util/util.go
index 947ab6e1c5de..ee972e2ee4ae 100644
--- a/util/util.go
+++ b/util/util.go
@@ -10,10 +10,7 @@
 package util
 
 import (
-	"encoding/json"
-	"fmt"
 	"io/ioutil"
-	"strings"
 
 	"github.com/ghodss/yaml"
 )
@@ -44,19 +41,17 @@ func Merge(in1 *map[string]interface{}, in2 *map[string]interface{}) *map[string
 	return &new
 }
 
-// Loads either a YAML or JSON file from the specified path and deserialises it into the provided interface.
-func LoadJsonOrYaml(filename string, addr interface{}) error {
+// Loads either a YAML or JSON file from the specified path and
+// deserialises it into the provided interface.
+func LoadData(filename string, addr interface{}) error {
 	file, err := ioutil.ReadFile(filename)
 	if err != nil {
 		return err
 	}
 
-	if strings.HasSuffix(filename, "json") {
-		err = json.Unmarshal(file, addr)
-	} else if strings.HasSuffix(filename, "yaml") || strings.HasSuffix(filename, "yml") {
-		err = yaml.Unmarshal(file, addr)
-	} else {
-		return fmt.Errorf("File format not supported. Must be JSON or YAML.")
+	err = yaml.Unmarshal(file, addr)
+	if err != nil {
+		return err
 	}
 
 	return nil