Skip to content

Commit

Permalink
feat(provider): add default value for shared config file
Browse files Browse the repository at this point in the history
  • Loading branch information
niuzhenguo committed Dec 25, 2024
1 parent b993762 commit 571fc7b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions huaweicloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"os"
"runtime"
"strings"
"sync"

Expand Down Expand Up @@ -2558,7 +2559,22 @@ func configureProvider(_ context.Context, d *schema.ResourceData, terraformVersi
if err != nil {
return nil, diag.FromErr(err)
}
} else if conf.Profile != "" {
conf.SharedConfigFile = fmt.Sprintf("%s/.hcloud/config.json", os.Getenv("HOME"))
if runtime.GOOS == "windows" {
conf.SharedConfigFile = fmt.Sprintf("%s/.hcloud/config.json", os.Getenv("USERPROFILE"))
}

_, err := os.Stat(conf.SharedConfigFile)
if os.IsNotExist(err) {
return nil, diag.FromErr(err)
}
err = readConfig(&conf)
if err != nil {
return nil, diag.FromErr(err)
}
}

if conf.Region == "" {
return nil, diag.Errorf("region should be provided")
}
Expand Down

0 comments on commit 571fc7b

Please sign in to comment.