diff options
| author | Paul Buetow <paul@buetow.org> | 2024-09-03 10:11:51 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-09-03 10:11:51 +0300 |
| commit | 3e33b52642b2b4d5a0c7a8d3a7a6bb269553be1f (patch) | |
| tree | 1fc4ef6c6cc98ec024b00d8874eec8e43485bef4 /internal/config/client/client.go | |
| parent | c907dd82c9ba2e7b1924b9f4febba68f9b04a38d (diff) | |
Partners and Servers are now slices
Diffstat (limited to 'internal/config/client/client.go')
| -rw-r--r-- | internal/config/client/client.go | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/internal/config/client/client.go b/internal/config/client/client.go index acb3503..d6f2939 100644 --- a/internal/config/client/client.go +++ b/internal/config/client/client.go @@ -1,22 +1,20 @@ package client import ( - "errors" "fmt" "log" "os" - "strings" "codeberg.org/snonux/gos/internal/config" ) type ClientConfig struct { - Server string `json:"Partner,omitempty"` - APIKey string `json:"APIKey,omitempty"` - Editor string `json:"Editor,omitempty"` - DataDir string `json:"StateDir,omitempty"` - ComposeFile string `json:"ComposeFile,omitempty"` - LogFile string `json:"LogFile,omitempty"` + Servers []string `json:"Servers,omitempty"` + APIKey string `json:"APIKey,omitempty"` + Editor string `json:"Editor,omitempty"` + DataDir string `json:"StateDir,omitempty"` + ComposeFile string `json:"ComposeFile,omitempty"` + LogFile string `json:"LogFile,omitempty"` } func New(configFile string) (ClientConfig, error) { @@ -28,7 +26,7 @@ func New(configFile string) (ClientConfig, error) { log.Println("Skipping config file:", err) } - conf.Server = config.EnvToStr("GOS_SERVERS", conf.Server) + conf.Servers = config.EnvToStrSlice("GOS_SERVERS", conf.Servers) conf.APIKey = config.EnvToStr("GOS_API_KEY", conf.APIKey) conf.Editor = config.EnvToStr("GOS_EDITOR", "EDITOR", conf.Editor, "vi") @@ -41,19 +39,3 @@ func New(configFile string) (ClientConfig, error) { return conf, nil } - -func (conf ClientConfig) Servers() ([]string, error) { - var servers []string - - for _, server := range strings.Split(conf.Server, ",") { - if server != "" { - servers = append(servers, server) - } - } - - if len(servers) == 0 { - return servers, errors.New("no server(s) configured") - } - - return servers, nil -} |
