Skip to content

Commit 44894e9

Browse files
committed
Test for the existence of the cloud name
1 parent 3ae0926 commit 44894e9

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

OpenStack.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/gophercloud/gophercloud/v2"
2525
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/flavors"
26+
"github.com/gophercloud/gophercloud/v2/openstack/config/clouds"
2627
"github.com/gophercloud/gophercloud/v2/openstack/image/v2/images"
2728
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks"
2829
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/keypairs"
@@ -71,6 +72,12 @@ func getServiceClient(ctx context.Context, serviceType string, cloud string) (cl
7172
return nil, fmt.Errorf("cloud name cannot be empty")
7273
}
7374

75+
// Test for the existence of the cloud name in clouds.yaml
76+
_, _, _, err = clouds.Parse(clouds.WithCloudName(cloud))
77+
if err != nil {
78+
return nil, err
79+
}
80+
7481
backoff := createDefaultBackoff(ctx)
7582

7683
err = wait.ExponentialBackoffWithContext(ctx, backoff, func(context.Context) (bool, error) {

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ require (
5050
golang.org/x/sys v0.42.0 // indirect
5151
golang.org/x/text v0.35.0 // indirect
5252
gopkg.in/inf.v0 v0.9.1 // indirect
53+
gopkg.in/yaml.v2 v2.4.0 // indirect
5354
gopkg.in/yaml.v3 v3.0.1 // indirect
5455
k8s.io/api v0.35.1 // indirect
5556
k8s.io/klog/v2 v2.130.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
132132
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
133133
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
134134
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
135+
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
136+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
135137
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
136138
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
137139
k8s.io/api v0.35.1 h1:0PO/1FhlK/EQNVK5+txc4FuhQibV25VLSdLMmGpDE/Q=

0 commit comments

Comments
 (0)