Skip to content

New Region parameter validation is too strict #1261

@maboehm

Description

@maboehm

#1256 added some new validation in order to prepare for changes in regional APIs for STACKIT.

My problem with that change is that the changed function ConfigureRegion() also checks the environment variable STACKIT_REGION. So if I have that variable set (because for example I want to manage buckets in a particular region), I cannot instantiate a serviceaccount client, as that will complain.

For example, the following can never work:

package main

import (
	"github.com/stackitcloud/stackit-sdk-go/services/objectstorage"
	"github.com/stackitcloud/stackit-sdk-go/services/serviceaccount"
)

func main() {
	// global APIs
	if _, err := serviceaccount.NewAPIClient(); err != nil {
		panic(err)
	}
	if _, err := objectstorage.NewAPIClient(); err != nil {
		panic(err)
	}
}
$ go run .
2025/01/07 15:13:13 WARNING: STACKIT will move to a new way of specifying regions, where the region is provided as a function argument instead of being set in the client configuration. Once all services have migrated, the methods to specify the region in the client configuration will be removed.
2025/01/07 15:13:13 WARNING: STACKIT will move to a new way of specifying regions, where the region is provided as a function argument instead of being set in the client configuration. Once all services have migrated, the methods to specify the region in the client configuration will be removed.
panic: configuring region: no region was provided, available regions are: [eu01]

goroutine 1 [running]:
main.main()
        /Users/marcel/dev/github.com/stackitcloud/ske-ci-infra/foo/main.go:14 +0x68
exit status 2

$ export STACKIT_REGION=eu01
$ go run .
2025/01/07 15:14:17 WARNING: STACKIT will move to a new way of specifying regions, where the region is provided as a function argument instead of being set in the client configuration. Once all services have migrated, the methods to specify the region in the client configuration will be removed.
panic: configuring region: 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

goroutine 1 [running]:
main.main()
        /Users/marcel/dev/github.com/stackitcloud/ske-ci-infra/foo/main.go:11 +0x78
exit status 2

Is this intended?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions