worker: make default config values more idiomatic

The only functional change is that
base_path = ""

will be now parsed as:

config.BasePath == ""

which wasn't possible before.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-06-28 13:24:32 +02:00 committed by Tom Gundersen
parent dc78b05a19
commit 9af6d1d43b

View file

@ -64,7 +64,11 @@ type workerConfig struct {
}
func parseConfig(file string) (*workerConfig, error) {
var config workerConfig
// set defaults
config := workerConfig{
BasePath: "/api/worker/v1",
}
_, err := toml.DecodeFile(file, &config)
if err != nil {
// Return error only when we failed to decode the file.
@ -75,9 +79,6 @@ func parseConfig(file string) (*workerConfig, error) {
logrus.Info("Configuration file not found, using defaults")
}
if config.BasePath == "" {
config.BasePath = "/api/worker/v1"
}
return &config, nil
}