Skip to content

Commit

Permalink
refactor readTerraformCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Sep 16, 2024
1 parent e1fae67 commit 59f1194
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,15 @@ func getToken() {
}

func readTerraformCredentials() (*Credentials, error) {
var configDir string

userConfigDir := os.UserHomeDir
if runtime.GOOS == "windows" {
var err error
configDir, err = os.UserConfigDir()
if err != nil {
return nil, fmt.Errorf("unable to get the config directory: %v", err)
}
} else {
var err error
configDir, err = os.UserHomeDir()
if err != nil {
return nil, fmt.Errorf("unable to get the home directory: %v", err)
}
userConfigDir = os.UserConfigDir
}

var err error
configDir, err := userConfigDir()
if err != nil {
return nil, fmt.Errorf("unable to get the home directory: %v", err)
}

credentialsPath := filepath.Join(configDir, ".terraform.d", "ceredentials.tfrc.json")
Expand Down

0 comments on commit 59f1194

Please sign in to comment.