summaryrefslogtreecommitdiffstats
path: root/config/configProvider.go
diff options
context:
space:
mode:
Diffstat (limited to 'config/configProvider.go')
-rw-r--r--config/configProvider.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/config/configProvider.go b/config/configProvider.go
index 335294d73..a7dc18960 100644
--- a/config/configProvider.go
+++ b/config/configProvider.go
@@ -16,6 +16,8 @@ package config
import (
"strings"
+ "github.com/spf13/cast"
+
"github.com/spf13/viper"
)
@@ -40,5 +42,16 @@ func FromConfigString(config, configType string) (Provider, error) {
return nil, err
}
return v, nil
+}
+// GetStringSlicePreserveString returns a string slice from the given config and key.
+// It differs from the GetStringSlice method in that if the config value is a string,
+// we do not attempt to split it into fields.
+func GetStringSlicePreserveString(cfg Provider, key string) []string {
+ sd := cfg.Get(key)
+ if sds, ok := sd.(string); ok {
+ return []string{sds}
+ } else {
+ return cast.ToStringSlice(sd)
+ }
}