From d6cfff4031f78429a25b02af45d3845c61caeb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 28 Jun 2022 10:19:40 +0200 Subject: [PATCH] Worker: treat empty config file the same as a missing one EOF while parsing the config file is now handled as an indication that the default config should be used, rather than a fatal error. --- internal/worker/config.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/worker/config.go b/internal/worker/config.go index bfbeaa18..baf531b9 100644 --- a/internal/worker/config.go +++ b/internal/worker/config.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "io/fs" "net/url" "os" "strings" @@ -71,11 +72,14 @@ func (fcw *FileConfigWrangler) WorkerConfig() (WorkerConfig, error) { err := fcw.loadConfig(configFilename, &wc) if err != nil { - if !errors.Is(err, fs.ErrNotExist) { + switch { + case errors.Is(err, fs.ErrNotExist): + // The config file not existing is fine; just use the defaults. + case errors.Is(err, io.EOF): + // The config file exists but is empty; treat as non-existent. + default: return wc, err } - - // The config file not existing is fine; just use the defaults. } fcw.wc = &wc