Skip to content

Commit

Permalink
Create config dir if using default configPath
Browse files Browse the repository at this point in the history
  • Loading branch information
mlsmaycon committed Jun 20, 2021
1 parent 41b50a0 commit 06c7af0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/wiretrustee/wiretrustee/connection"
"io/ioutil"
"os"
"path/filepath"
)

// Config Configuration type
Expand All @@ -23,6 +24,15 @@ type Config struct {

//Write writes configPath to a file
func (cfg *Config) Write(path string) error {

if path == defaultConfigPath {
configDir := filepath.Dir(path)
err := os.MkdirAll(configDir, 0750)
if err != nil {
return err
}
}

bs, err := json.Marshal(cfg)
if err != nil {
return err
Expand Down

0 comments on commit 06c7af0

Please sign in to comment.