Skip to content

Commit abc5f04

Browse files
committed
Allow custom region from config
1 parent 8effe29 commit abc5f04

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cloudstack.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type CSConfig struct {
4545
SSLNoVerify bool `gcfg:"ssl-no-verify"`
4646
ProjectID string `gcfg:"project-id"`
4747
Zone string `gcfg:"zone"`
48+
Region string `gcfg:"region"`
4849
}
4950
}
5051

@@ -53,6 +54,7 @@ type CSCloud struct {
5354
client *cloudstack.CloudStackClient
5455
projectID string // If non-"", all resources will be created within this project
5556
zone string
57+
region string
5658
}
5759

5860
func init() {
@@ -85,6 +87,7 @@ func newCSCloud(cfg *CSConfig) (*CSCloud, error) {
8587
cs := &CSCloud{
8688
projectID: cfg.Global.ProjectID,
8789
zone: cfg.Global.Zone,
90+
region: cfg.Global.Region,
8891
}
8992

9093
if cfg.Global.APIURL != "" && cfg.Global.APIKey != "" && cfg.Global.SecretKey != "" {
@@ -190,7 +193,12 @@ func (cs *CSCloud) GetZone(ctx context.Context) (cloudprovider.Zone, error) {
190193

191194
klog.V(2).Infof("Current zone is %v", cs.zone)
192195
zone.FailureDomain = cs.zone
193-
zone.Region = cs.zone
196+
197+
if cs.region == "" {
198+
zone.Region = cs.zone
199+
} else {
200+
zone.Region = cs.region
201+
}
194202

195203
return zone, nil
196204
}

0 commit comments

Comments
 (0)