mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-12-09 05:36:27 +08:00
NEW FEATURE: Empty creds.json should not be an error (#3844)
This commit is contained in:
parent
3bf0c5a318
commit
4d29c2c2a5
1 changed files with 5 additions and 1 deletions
|
|
@ -39,6 +39,10 @@ func LoadProviderConfigs(fname string) (map[string]map[string]string, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Empty file? Add an empty json object.
|
||||
if len(strings.TrimSpace(string(dat))) == 0 {
|
||||
dat = []byte(`{}`)
|
||||
}
|
||||
}
|
||||
|
||||
s := string(dat)
|
||||
|
|
@ -76,7 +80,7 @@ func isExecutable(filename string) bool {
|
|||
func readCredsFile(filename string) ([]byte, error) {
|
||||
dat, err := utfutil.ReadFile(filename, utfutil.POSIX)
|
||||
if err != nil {
|
||||
// no creds file is ok. Bind requires nothing for example. Individual providers will error if things not found.
|
||||
// no creds file is ok. `bind` requires nothing for example. Individual providers will error if things not found.
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Printf("INFO: Config file %q does not exist. Skipping.\n", filename)
|
||||
return []byte{}, nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue