altsrc: allow nested defaults in yaml files

Previously, defaults specified as nested keys in a yaml file would not
be recognized, i.e. `top: \n  bottom: key` would not be accessible using
the name `top.bottom`, but `top.bottom: key` would. These changes
support using nested keys by traversing the configuration tree if the
key name uses '.' as a delimiter.
This commit is contained in:
rob boll
2016-04-29 12:33:59 -04:00
parent 9fec0fad02
commit 36a5323a47
4 changed files with 232 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ type yamlSourceContext struct {
// NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath.
func NewYamlSourceFromFile(file string) (InputSourceContext, error) {
ysc := &yamlSourceContext{FilePath: file}
var results map[string]interface{}
var results map[interface{}]interface{}
err := readCommandYaml(ysc.FilePath, &results)
if err != nil {
return nil, fmt.Errorf("Unable to load Yaml file '%s': inner error: \n'%v'", ysc.FilePath, err.Error())