Skip to content

Commit

Permalink
Create config directory if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Aug 1, 2023
1 parent 9f92065 commit 9651a59
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/bbctl/authconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ func loadConfig(path string) (ret *Config, err error) {
}

func (cfg *Config) Save() error {
dirName := filepath.Dir(cfg.Path)
err := os.MkdirAll(dirName, 0700)
if err != nil {
return fmt.Errorf("failed to create config directory at %s: %w", dirName, err)
}
file, err := os.OpenFile(cfg.Path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return fmt.Errorf("failed to open config at %s for writing: %v", cfg.Path, err)
Expand Down

0 comments on commit 9651a59

Please sign in to comment.