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.
This commit is contained in:
parent
fb89658530
commit
d6cfff4031
@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@ -71,11 +72,14 @@ func (fcw *FileConfigWrangler) WorkerConfig() (WorkerConfig, error) {
|
|||||||
err := fcw.loadConfig(configFilename, &wc)
|
err := fcw.loadConfig(configFilename, &wc)
|
||||||
|
|
||||||
if err != nil {
|
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
|
return wc, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// The config file not existing is fine; just use the defaults.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fcw.wc = &wc
|
fcw.wc = &wc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user