Skip to content

Commit

Permalink
Azure: update to use provider interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jhixson74 committed Mar 5, 2024
1 parent 0af45c6 commit 2a022e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
5 changes: 3 additions & 2 deletions pkg/asset/machines/azure/azuremachines.go
Expand Up @@ -45,8 +45,10 @@ func GenerateMachines(platform *azure.Platform, pool *types.MachinePool, userDat
return nil, fmt.Errorf("failed to create machineapi.TagSpecifications from UserTags: %w", err)
}

var image *capz.Image = &capz.Image{}
image := &capz.Image{}
osImage := mpool.OSImage
galleryName := strings.ReplaceAll(clusterID, "-", "_")

switch {
case osImage.Publisher != "":
image = &capz.Image{
Expand All @@ -61,7 +63,6 @@ func GenerateMachines(platform *azure.Platform, pool *types.MachinePool, userDat
}
case useImageGallery:
// image gallery names cannot have dashes
galleryName := strings.ReplaceAll(clusterID, "-", "_")
id := clusterID
if hyperVGen == "V2" {
id += genV2Suffix
Expand Down
20 changes: 7 additions & 13 deletions pkg/infrastructure/azure/azure.go
Expand Up @@ -23,26 +23,20 @@ import (
aztypes "github.com/openshift/installer/pkg/types/azure"
)

var _ clusterapi.Provider = (*Provider)(nil)

// Provider implements Azure CAPI installation.
type Provider struct{}

// InfraProvider is the Azure SDK infra provider.
type InfraProvider struct{}

// InitializeProvider initializes the Azure SDK provider.
func InitializeProvider() clusterapi.Provider {
return &InfraProvider{}
type Provider struct {
clusterapi.InfraProvider
}

var _ clusterapi.PreProvider = Provider{}

// Name returns the name of the provider.
func (p *InfraProvider) Name() string {
return "azure"
func (p Provider) Name() string {
return aztypes.Name
}

// PreProvision is called before provisioning using CAPI controllers has begun.
func (p *InfraProvider) PreProvision(ctx context.Context, in clusterapi.PreProvisionInput) error {
func (p Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionInput) error {
session, err := in.InstallConfig.Azure.Session()
if err != nil {
return fmt.Errorf("failed to get session: %w", err)
Expand Down

0 comments on commit 2a022e5

Please sign in to comment.