Improve config

This commit is contained in:
Torjus Håkestad 2022-01-19 00:39:49 +01:00
parent 41e82fb21e
commit 94e1920098

View File

@ -22,15 +22,13 @@ type ServerStoreConfig struct {
func ServerConfigFromReader(r io.Reader) (*ServerConfig, error) { func ServerConfigFromReader(r io.Reader) (*ServerConfig, error) {
decoder := toml.NewDecoder(r) decoder := toml.NewDecoder(r)
var c ServerConfig c := ServerConfig{
Store: &ServerStoreConfig{},
}
if err := decoder.Decode(&c); err != nil { if err := decoder.Decode(&c); err != nil {
return nil, fmt.Errorf("error decoding server config: %w", err) return nil, fmt.Errorf("error decoding server config: %w", err)
} }
if c.Store == nil {
c.Store = &ServerStoreConfig{}
}
c.updateFromEnv() c.updateFromEnv()
return &c, nil return &c, nil