Fix yaml file loader
* fix typo (yamlSourceLoader -> yamlSourceContext) * fix function return type (NewYamlSourceFromFlagFunc) Also fixed build tags to properly build on >=go1.2 Signed-off-by: Jesse Szwedko <jesse.szwedko@gmail.com>
This commit is contained in:
parent
aca5b047ed
commit
ad7ed77a7e
@ -1,7 +1,7 @@
|
|||||||
// Disabling building of yaml support in cases where golang is 1.0 or 1.1
|
// Disabling building of yaml support in cases where golang is 1.0 or 1.1
|
||||||
// as the encoding library is not implemented or supported.
|
// as the encoding library is not implemented or supported.
|
||||||
|
|
||||||
// +build !go1,!go1.1
|
// +build go1.2
|
||||||
|
|
||||||
package altsrc
|
package altsrc
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Disabling building of yaml support in cases where golang is 1.0 or 1.1
|
// Disabling building of yaml support in cases where golang is 1.0 or 1.1
|
||||||
// as the encoding library is not implemented or supported.
|
// as the encoding library is not implemented or supported.
|
||||||
|
|
||||||
// +build !go1,!go1.1
|
// +build go1.2
|
||||||
|
|
||||||
package altsrc
|
package altsrc
|
||||||
|
|
||||||
@ -23,19 +23,19 @@ type yamlSourceContext struct {
|
|||||||
|
|
||||||
// NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath.
|
// NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath.
|
||||||
func NewYamlSourceFromFile(file string) (InputSourceContext, error) {
|
func NewYamlSourceFromFile(file string) (InputSourceContext, error) {
|
||||||
ymlLoader := &yamlSourceLoader{FilePath: file}
|
ysc := &yamlSourceContext{FilePath: file}
|
||||||
var results map[string]interface{}
|
var results map[string]interface{}
|
||||||
err := readCommandYaml(ysl.FilePath, &results)
|
err := readCommandYaml(ysc.FilePath, &results)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Unable to load Yaml file '%s': inner error: \n'%v'", filePath, err.Error())
|
return nil, fmt.Errorf("Unable to load Yaml file '%s': inner error: \n'%v'", ysc.FilePath, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return &MapInputSource{valueMap: results}, nil
|
return &MapInputSource{valueMap: results}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context.
|
// NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context.
|
||||||
func NewYamlSourceFromFlagFunc(flagFileName string) func(InputSourceContext, error) {
|
func NewYamlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) {
|
||||||
return func(context cli.Context) {
|
return func(context *cli.Context) (InputSourceContext, error) {
|
||||||
filePath := context.String(flagFileName)
|
filePath := context.String(flagFileName)
|
||||||
return NewYamlSourceFromFile(filePath)
|
return NewYamlSourceFromFile(filePath)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user