Skip to content

Commit d1f240d

Browse files
Merge pull request openshift#8209 from 2uasimojo/OSASINFRA-3421/customizable-clientopts
OSASINFRA-3421: OpenStack: Customizable clientOpts for CheckNetworkEx…
2 parents e21173a + e181b1c commit d1f240d

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

pkg/asset/machines/clusterapi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ func (c *ClusterAPI) Generate(dependencies asset.Parents) error {
333333
trunkSupport, err := openstack.CheckNetworkExtensionAvailability(
334334
ic.Platform.OpenStack.Cloud,
335335
"trunk",
336+
nil,
336337
)
337338
if err != nil {
338339
return fmt.Errorf("failed to check for trunk support: %w", err)

pkg/asset/machines/master.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ func (m *Master) Generate(dependencies asset.Parents) error {
313313
trunkSupport, err := openstack.CheckNetworkExtensionAvailability(
314314
ic.Platform.OpenStack.Cloud,
315315
"trunk",
316+
nil,
316317
)
317318
if err != nil {
318319
return fmt.Errorf("failed to check for trunk support: %w", err)

pkg/asset/machines/openstack/machines.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/gophercloud/gophercloud"
88
netext "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions"
99
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
10+
"github.com/gophercloud/utils/openstack/clientconfig"
1011
"github.com/pkg/errors"
1112
corev1 "k8s.io/api/core/v1"
1213
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -375,8 +376,13 @@ func failureDomainsFromSpec(mpool openstack.MachinePool) []machinev1.OpenStackFa
375376

376377
// CheckNetworkExtensionAvailability interrogates the OpenStack API to validate
377378
// the availability of a given Neutron extension.
378-
func CheckNetworkExtensionAvailability(cloud, alias string) (bool, error) {
379-
opts := openstackdefaults.DefaultClientOpts(cloud)
379+
// The `opts` parameter is provided for external consumers needing to configure
380+
// the client e.g. with custom certs. If unspecified (nil), a default client is
381+
// built based on the specified `cloud`.
382+
func CheckNetworkExtensionAvailability(cloud, alias string, opts *clientconfig.ClientOpts) (bool, error) {
383+
if opts == nil {
384+
opts = openstackdefaults.DefaultClientOpts(cloud)
385+
}
380386
conn, err := openstackdefaults.NewServiceClient("network", opts)
381387
if err != nil {
382388
return false, err

pkg/asset/machines/worker.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ func (w *Worker) Generate(dependencies asset.Parents) error {
587587
trunkSupport, err := openstack.CheckNetworkExtensionAvailability(
588588
ic.Platform.OpenStack.Cloud,
589589
"trunk",
590+
nil,
590591
)
591592
if err != nil {
592593
return fmt.Errorf("failed to check for trunk support: %w", err)

0 commit comments

Comments
 (0)