Skip to content

Commit

Permalink
Merge pull request #126 from jacec/jacec-minor-updates
Browse files Browse the repository at this point in the history
simple format updates to config.go and updated depdency to latest yam…
  • Loading branch information
takahi-i committed Aug 4, 2015
2 parents 2831ecf + 901411b commit 1753962
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{
Expand All @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit 1753962

Please sign in to comment.