Skip to content

Commit

Permalink
Fix distribworks#334. Fix specifying tags via cli args
Browse files Browse the repository at this point in the history
  • Loading branch information
jianhengyi committed Mar 6, 2018
1 parent 24393e0 commit 96be7e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dkron/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ func NewConfig(args []string, agent *AgentCommand) *Config {
cmdFlags.VisitAll(func(f *flag.Flag) {
v := strings.Replace(f.Name, "-", "_", -1)
if f.Value.String() != f.DefValue {
viper.Set(v, f.Value.String())
if sliceValue, ok := f.Value.(*AppendSliceValue); ok {
viper.Set(v, ([]string)(*sliceValue))
} else {
viper.Set(v, f.Value.String())
}
} else {
viper.SetDefault(v, f.Value.String())
}
Expand Down
4 changes: 4 additions & 0 deletions dkron/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ func TestReadConfigTags(t *testing.T) {
assert.NotContains(t, config.Tags, "foo")
assert.Contains(t, config.Tags, "monthy")
assert.Equal(t, "python", config.Tags["monthy"])

config = NewConfig([]string{"-tag", "t1=v1", "-tag", "t2=v2"}, a)
assert.Equal(t, "v1", config.Tags["t1"])
assert.Equal(t, "v2", config.Tags["t2"])
}

0 comments on commit 96be7e7

Please sign in to comment.