Skip to content

Commit

Permalink
Add support for the CLI v2 config path
Browse files Browse the repository at this point in the history
This is to support downgrades from CLI v2 back to v1.
The CLI will still default to using the old path, and the new path will only be used if a file doesn't exist at the old path BUT does exist at the new path.
  • Loading branch information
Piccirello committed Jan 20, 2020
1 parent 63228e4 commit 8823e33
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkg/configuration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,22 @@ var UserConfigPath string
var configContents models.ConfigFile

func init() {
fileName := ".doppler.yaml"
configDir := utils.ConfigDir()
if utils.Exists(configDir) {
UserConfigPath = filepath.Join(configDir, fileName)
} else {
UserConfigPath = filepath.Join(utils.HomeDir(), fileName)
if !utils.Exists(configDir) {
configDir = utils.HomeDir()
}

fileName := ".doppler.yaml"
filePath := filepath.Join(configDir, fileName)

// support the cli v2 config path to allow downgrades
cliV2Path := filepath.Join(configDir, "doppler", fileName)
if !utils.Exists(filePath) && utils.Exists(cliV2Path) {
filePath = cliV2Path
}

UserConfigPath = filePath

if !exists() {
if jsonExists() {
migrateJSONToYaml()
Expand Down

0 comments on commit 8823e33

Please sign in to comment.