Attempt to create directory structure for config file if missing
This commit is contained in:
parent
342c3ea565
commit
f0a4efb242
|
@ -14,6 +14,7 @@ import (
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -169,8 +170,13 @@ func (f *ConfigurationFile) Parse(path string, internal bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Create(path); err != nil {
|
b := strings.TrimSuffix(path, filepath.Base(path))
|
||||||
return errors.WithStack(err)
|
if err := os.MkdirAll(b, 0755); err != nil {
|
||||||
|
return errors.Wrap(err, "failed to create base directory for missing configuration file")
|
||||||
|
} else {
|
||||||
|
if _, err := os.Create(path); err != nil {
|
||||||
|
return errors.Wrap(err, "failed to create missing configuration file")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return f.Parse(path, true)
|
return f.Parse(path, true)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user