This is an automated email from the ASF dual-hosted git repository.

vishesh pushed a commit to branch allow-custom-region
in repository 
https://gitbox.apache.org/repos/asf/cloudstack-kubernetes-provider.git

commit abc5f0479d685d37792a53e0d6cb80e285431362
Author: vishesh92 <[email protected]>
AuthorDate: Tue Nov 25 14:27:45 2025 +0100

    Allow custom region from config
---
 cloudstack.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/cloudstack.go b/cloudstack.go
index 8d78a861..b989c8f7 100644
--- a/cloudstack.go
+++ b/cloudstack.go
@@ -45,6 +45,7 @@ type CSConfig struct {
                SSLNoVerify bool   `gcfg:"ssl-no-verify"`
                ProjectID   string `gcfg:"project-id"`
                Zone        string `gcfg:"zone"`
+               Region      string `gcfg:"region"`
        }
 }
 
@@ -53,6 +54,7 @@ type CSCloud struct {
        client    *cloudstack.CloudStackClient
        projectID string // If non-"", all resources will be created within 
this project
        zone      string
+       region    string
 }
 
 func init() {
@@ -85,6 +87,7 @@ func newCSCloud(cfg *CSConfig) (*CSCloud, error) {
        cs := &CSCloud{
                projectID: cfg.Global.ProjectID,
                zone:      cfg.Global.Zone,
+               region:    cfg.Global.Region,
        }
 
        if cfg.Global.APIURL != "" && cfg.Global.APIKey != "" && 
cfg.Global.SecretKey != "" {
@@ -190,7 +193,12 @@ func (cs *CSCloud) GetZone(ctx context.Context) 
(cloudprovider.Zone, error) {
 
        klog.V(2).Infof("Current zone is %v", cs.zone)
        zone.FailureDomain = cs.zone
-       zone.Region = cs.zone
+
+       if cs.region == "" {
+               zone.Region = cs.zone
+       } else {
+               zone.Region = cs.region
+       }
 
        return zone, nil
 }

Reply via email to