Skip to content

Commit

Permalink
Merge pull request #283 from erdii/mkdir-config-folder-on-init
Browse files Browse the repository at this point in the history
create config folder before creating config file within it
  • Loading branch information
openshift-merge-bot[bot] committed May 17, 2024
2 parents 9f964ec + 692b118 commit 1f16815
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bufio"
"fmt"
"os"
"path/filepath"
"slices"
"sort"
"strings"
Expand Down Expand Up @@ -212,6 +213,12 @@ var initCmd = &cobra.Command{
return nil
}

directory := filepath.Dir(cfgFile)
err = os.MkdirAll(directory, 0o750)
if err != nil {
return fmt.Errorf("creating config file folder %s: %w", directory, err)
}

err = viper.WriteConfig()
if err != nil {
return err
Expand Down Expand Up @@ -575,10 +582,8 @@ func buildNewConfig(legacyData map[string]any, existingConfig, showSensitiveValu

configMap := createConfigurationMap(legacyData, migrate)
return configMap, nil
}

// If assumeYes is not true, prompt the user to write a new config
if !assumeYes {
} else {
// If assumeYes is not true, prompt the user to write a new config
writeConfig, err = promptUserToWriteConfig(existingConfig)
if err != nil {
return nil, err
Expand Down

0 comments on commit 1f16815

Please sign in to comment.