Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Release (2025-01-08)

- **Bugfix:** `ConfigureRegion` does not return an error if a region is set by an enviroment variable.

## Release (2025-01-07)

- `postgresflex`: [0.16.1](services/postgresflex/CHANGELOG.md#v0161-2025-xx-yy)
Expand Down
4 changes: 4 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.15.1 (2025-01-08)

- **Bugfix:** `ConfigureRegion` does not return an error if a region is set by an enviroment variable.

## v0.15.0 (2025-01-02)

- **Breaking Change:**: `ConfigureRegion` returns an error if a region is specified for a global URL.
Expand Down
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