diff --git a/pkg/config/config.go b/pkg/config/config.go index e761bed..2919c67 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1,6 +1,7 @@ package config import ( + "strings" "sync" "github.com/afex/hystrix-go/hystrix" @@ -95,7 +96,7 @@ func ConcurrentOpacityCheckingEnabled() bool { return getConfig().enableConcurrentOpacityChecking } -// DefaultParams returns string of default parameters which will be applied to all image request, following the existing contract -func DefaultParams() string { - return getConfig().defaultParams +// DefaultParams returns []string of default parameters (separated by semicolon) which will be applied to all image request, following the existing contract +func DefaultParams() []string { + return strings.Split(getConfig().defaultParams, ";") } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index e89ef4c..dc81bd7 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -16,10 +16,6 @@ func TestConfigCasesWithStringValues(t *testing.T) { key: "log.level", callFunc: LogLevel, }, - { - key: "defaultParams", - callFunc: DefaultParams, - }, } for _, c := range cases { @@ -67,3 +63,22 @@ func TestConfigCasesWithIntValues(t *testing.T) { assert.Equal(t, 0, v.GetInt("nonexistingkey")) } + +func TestConfigCasesWithStringSliceValues(t *testing.T) { + v := Viper() + v.Set("defaultParams", "auto=compress") + Update() + cases := []struct { + key string + callFunc func() []string + }{ + { + key: "defaultParams", + callFunc: DefaultParams, + }, + } + + for _, c := range cases { + assert.Equal(t, v.GetStringSlice(c.key), c.callFunc()) + } +}