parse []string from env
parent
a7e254ff94
commit
a8d1d69f63
|
|
@ -17,7 +17,7 @@ type Config struct {
|
|||
Debug bool
|
||||
InitializeSlack bool
|
||||
SlackToken string
|
||||
SlackChannels string
|
||||
SlackChannels []string
|
||||
PostgresConn string
|
||||
BasicAuthUser string
|
||||
BasicAuthPassword string
|
||||
|
|
@ -73,6 +73,10 @@ func newConfigFromEnv(ctx context.Context, getEnv func(string) string) (Config,
|
|||
return Config{}, err
|
||||
}
|
||||
m[k] = got
|
||||
case nil, []interface{}:
|
||||
m[k] = strings.Split(s, ",")
|
||||
default:
|
||||
return Config{}, fmt.Errorf("not impl: parse %s as %T", envK, v)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ func TestNewConfig(t *testing.T) {
|
|||
return "1"
|
||||
case "INITIALIZE_SLACK":
|
||||
return "true"
|
||||
case "SLACK_CHANNELS":
|
||||
return "x,y"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
|
@ -22,5 +24,7 @@ func TestNewConfig(t *testing.T) {
|
|||
t.Error(got)
|
||||
} else if !got.InitializeSlack {
|
||||
t.Error(got)
|
||||
} else if len(got.SlackChannels) != 2 || got.SlackChannels[0] != "x" || got.SlackChannels[1] != "y" {
|
||||
t.Error(got)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue