diff --git a/internal/config/config.go b/internal/config/config.go index 16b24f9..5cdfe9c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -2,6 +2,7 @@ package config import ( "errors" + "fmt" ) type Config struct { @@ -60,6 +61,28 @@ func (p Params) GetBool(key string) (bool, error) { return boolValue, nil } +func (p Params) GetStringSlice(key string) ([]string, error) { + value, ok := p[key] + if !ok { + return nil, ErrParamNotFound + } + + interfaceSlice, ok := value.([]any) + if !ok { + return nil, errors.New("not a slice") + } + + stringSlice := make([]string, len(interfaceSlice)) + for i, v := range interfaceSlice { + str, ok := v.(string) + if !ok { + return nil, fmt.Errorf("element at index %d is not a string", i) + } + stringSlice[i] = str + } + return stringSlice, nil +} + type ModuleConfig struct { Id string `json:"id"` Type string `json:"type"`