Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,12 @@ func ConfigureRegion(cfg *Configuration) error {
availableRegions = append(availableRegions, strings.TrimSuffix(regionWithDotSuffix, "."))
}

isRegionSetByEnv := false
if cfg.Region == "" {
// Check region
envVarRegion, _ := os.LookupEnv("STACKIT_REGION")
cfg.Region = envVarRegion
isRegionSetByEnv = true
}

if oasRegion.DefaultValue != "" && oasRegion.DefaultValue != global {
Expand All @@ -524,9 +526,9 @@ func ConfigureRegion(cfg *Configuration) error {
return fmt.Errorf("the provided region is not available for this API, available regions are: %s", availableRegions)
}
// Global API.
// If a region is provided by the user via WithRegion() or via environment variable return an error.
// If a region is provided by the user via WithRegion() return an error.
// The region is provided as a function argument instead of being set in the client configuration.
if cfg.Region != "" {
if cfg.Region != "" && !isRegionSetByEnv {
return fmt.Errorf("this API does not support setting a region in the the client configuration, please check if the region can be specified as a function parameter")
}
// If the url is a template, generated using deprecated config.json, the region variable is replaced
Expand Down
Loading