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
cblecker committed Jun 13, 2023
1 parent d933c9e commit 5018ce6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/ocm-backplane/config/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"fmt"
"os"
"path"

"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -43,6 +44,13 @@ func setConfig(cmd *cobra.Command, args []string) error {
bpConfig.SessionDirectory = viper.GetString("session-dir")
}

// Create config directory if it doesn't exist
if dir, err := os.Stat(path.Dir(configPath)); os.IsNotExist(err) || !dir.IsDir() {
if err := os.Mkdir(path.Dir(configPath), 0750); err != nil {
return err
}
}

switch args[0] {
case URLConfigVar:
bpConfig.URL = args[1]
Expand Down

0 comments on commit 5018ce6

Please sign in to comment.