Skip to content

Commit

Permalink
chore(config): if the config dir doesn't exist, create it
Browse files Browse the repository at this point in the history
Signed-off-by: Huamin Chen <[email protected]>
  • Loading branch information
rootfs committed Dec 2, 2024
1 parent ac79d14 commit 0f4fe82
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ func newConfig() (*Config, error) {

s, err := os.Stat(absBaseDir)
if os.IsNotExist(err) {
return nil, fmt.Errorf("config-dir %s does not exist", BaseDir)
// if the directory does not exist, create it
if err := os.MkdirAll(absBaseDir, 0755); err != nil {
return nil, fmt.Errorf("config-dir %s does not exist", BaseDir)
}
s, err = os.Stat(absBaseDir)
if err != nil {
return nil, fmt.Errorf("failed to stat config-dir %s: %w", BaseDir, err)
}
}
if !s.IsDir() {
return nil, fmt.Errorf("config-dir %s is not a directory", BaseDir)
Expand Down

0 comments on commit 0f4fe82

Please sign in to comment.