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"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -169,8 +170,13 @@ func (f *ConfigurationFile) Parse(path string, internal bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
b := strings.TrimSuffix(path, filepath.Base(path))
|
||||
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.WithStack(err)
|
||||
return errors.Wrap(err, "failed to create missing configuration file")
|
||||
}
|
||||
}
|
||||
|
||||
return f.Parse(path, true)
|
||||
|
|
Loading…
Reference in New Issue
Block a user