9912: Support YAML config files. Change default config file paths to /etc/arvados...
[arvados.git] / sdk / go / config / load.go
index 143be8be23eedf319de1a8bf90ec3428dc2c944a..9c65d65e84a57d9120d69dd84912615ff3949e35 100644 (file)
@@ -1,21 +1,22 @@
 package config
 
 import (
-       "encoding/json"
        "fmt"
        "io/ioutil"
+
+       "github.com/ghodss/yaml"
 )
 
 // LoadFile loads configuration from the file given by configPath and
 // decodes it into cfg.
 //
-// Currently, only JSON is supported. Support for YAML is anticipated.
+// YAML and JSON formats are supported.
 func LoadFile(cfg interface{}, configPath string) error {
        buf, err := ioutil.ReadFile(configPath)
        if err != nil {
                return err
        }
-       err = json.Unmarshal(buf, cfg)
+       err = yaml.Unmarshal(buf, cfg)
        if err != nil {
                return fmt.Errorf("Error decoding config %q: %v", configPath, err)
        }