Skip to content

Commit

Permalink
allow providing some client options when generating OpenStack Machine…
Browse files Browse the repository at this point in the history
…Sets
  • Loading branch information
Joel Diaz committed Oct 5, 2020
1 parent b2199d8 commit 1800a06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions pkg/asset/machines/openstack/machines.go
Expand Up @@ -40,7 +40,7 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine

mpool := pool.Platform.OpenStack
platform := config.Platform.OpenStack
trunkSupport, err := checkNetworkExtensionAvailability(platform.Cloud, "trunk")
trunkSupport, err := checkNetworkExtensionAvailability(platform.Cloud, "trunk", nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -174,10 +174,11 @@ func generateProvider(clusterID string, platform *openstack.Platform, mpool *ope
return &spec, nil
}

func checkNetworkExtensionAvailability(cloud, alias string) (bool, error) {
opts := &clientconfig.ClientOpts{
Cloud: cloud,
func checkNetworkExtensionAvailability(cloud, alias string, opts *clientconfig.ClientOpts) (bool, error) {
if opts == nil {
opts = &clientconfig.ClientOpts{}
}
opts.Cloud = cloud

conn, err := clientconfig.NewServiceClient("network", opts)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/asset/machines/openstack/machinesets.go
Expand Up @@ -4,6 +4,7 @@ package openstack
import (
"fmt"

"github.com/gophercloud/utils/openstack/clientconfig"
clusterapi "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -13,7 +14,7 @@ import (
)

// MachineSets returns a list of machinesets for a machinepool.
func MachineSets(clusterID string, config *types.InstallConfig, pool *types.MachinePool, osImage, role, userDataSecret string) ([]*clusterapi.MachineSet, error) {
func MachineSets(clusterID string, config *types.InstallConfig, pool *types.MachinePool, osImage, role, userDataSecret string, clientOpts *clientconfig.ClientOpts) ([]*clusterapi.MachineSet, error) {
if configPlatform := config.Platform.Name(); configPlatform != openstack.Name {
return nil, fmt.Errorf("non-OpenStack configuration: %q", configPlatform)
}
Expand All @@ -22,7 +23,7 @@ func MachineSets(clusterID string, config *types.InstallConfig, pool *types.Mach
}
platform := config.Platform.OpenStack
mpool := pool.Platform.OpenStack
trunkSupport, err := checkNetworkExtensionAvailability(platform.Cloud, "trunk")
trunkSupport, err := checkNetworkExtensionAvailability(platform.Cloud, "trunk", clientOpts)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/asset/machines/worker.go
Expand Up @@ -8,6 +8,7 @@ import (
"strings"

"github.com/ghodss/yaml"
openstackclientconfig "github.com/gophercloud/utils/openstack/clientconfig"
baremetalapi "github.com/metal3-io/cluster-api-provider-baremetal/pkg/apis"
baremetalprovider "github.com/metal3-io/cluster-api-provider-baremetal/pkg/apis/baremetal/v1alpha1"
gcpapi "github.com/openshift/cluster-api-provider-gcp/pkg/apis"
Expand Down Expand Up @@ -352,7 +353,7 @@ func (w *Worker) Generate(dependencies asset.Parents) error {

imageName, _ := rhcosutils.GenerateOpenStackImageName(string(*rhcosImage), clusterID.InfraID)

sets, err := openstack.MachineSets(clusterID.InfraID, ic, &pool, imageName, "worker", "worker-user-data")
sets, err := openstack.MachineSets(clusterID.InfraID, ic, &pool, imageName, "worker", "worker-user-data", &openstackclientconfig.ClientOpts{})
if err != nil {
return errors.Wrap(err, "failed to create worker machine objects")
}
Expand Down

0 comments on commit 1800a06

Please sign in to comment.