diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index cd3c482..eaec6fd 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -4,7 +4,7 @@ "Deps": [ { "ImportPath": "github.com/go-yaml/yaml", - "Rev": "1b9791953ba4027efaeb728c7355e542a203be5e" + "Rev": "7ad95dd0798a40da1ccdff6dff35fd177b5edf40" }, { "ImportPath": "github.com/ainoya/glog", diff --git a/config/config.go b/config/config.go index c21a17f..42a3d5a 100644 --- a/config/config.go +++ b/config/config.go @@ -44,14 +44,14 @@ func LoadOpts(arguments []string) (*Opts, error) { var stopOnAnyFailure bool var printVersion bool var threshold string - var log_dir string + var logDir string var mode string fs.StringVar(&pipelineFilePath, "c", "./pipeline.yml", "pipeline.yml file") fs.BoolVar(&stopOnAnyFailure, "f", false, "Skip execution of subsequent stage after failing to exec the upstream stage.") fs.BoolVar(&printVersion, "v", false, "Print the version information and exit.") fs.StringVar(&threshold, "threshold", "INFO", "Log events at or above this severity are logged.") - fs.StringVar(&log_dir, "log_dir", "", "Log files will be written to this directory.") + fs.StringVar(&logDir, "logDir", "", "Log files will be written to this directory.") fs.StringVar(&mode, "mode", "local", "Execution mode (local or service).") if err := fs.Parse(arguments); err != nil { @@ -60,8 +60,8 @@ func LoadOpts(arguments []string) (*Opts, error) { flag.CommandLine.Lookup("stderrthreshold").Value.Set(threshold) - if log_dir != "" { - flag.CommandLine.Lookup("log_dir").Value.Set(log_dir) + if logDir != "" { + flag.CommandLine.Lookup("logDir").Value.Set(logDir) } return &Opts{ @@ -72,6 +72,8 @@ func LoadOpts(arguments []string) (*Opts, error) { }, nil } +// ReadConfig reads the supplied configuration file and returns the +// corresponding map or an error. func ReadConfig(configFilePath string) (*map[interface{}]interface{}, error) { data, err := ioutil.ReadFile(configFilePath) if err != nil { @@ -80,6 +82,8 @@ func ReadConfig(configFilePath string) (*map[interface{}]interface{}, error) { return ReadConfigBytes(data) } +// ReadConfigBytes reads the supplied configuration byte[] and returns the +// corresponding map or an error. func ReadConfigBytes(configSetting []byte) (*map[interface{}]interface{}, error) { configData := make(map[interface{}]interface{}) err := yaml.Unmarshal(configSetting, &configData)