Skip to content

Commit 21daed5

Browse files
committed
pkg/infra/azure: remove PreProvider hooks
Now that resource group creation is handled by CAPZ it is no longer necessary to have a pre-provider hook for Azure. This commit refactors the code to remove the hook and deduplicate code.
1 parent 2be152a commit 21daed5

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

pkg/infrastructure/azure/azure.go

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ type Provider struct {
5555
Tags map[string]*string
5656
}
5757

58-
var _ clusterapi.PreProvider = (*Provider)(nil)
5958
var _ clusterapi.InfraReadyProvider = (*Provider)(nil)
6059
var _ clusterapi.PostProvider = (*Provider)(nil)
6160
var _ clusterapi.IgnitionProvider = (*Provider)(nil)
@@ -83,23 +82,6 @@ func (p Provider) ProvisionTimeout() time.Duration {
8382
// in the status and should use the API load balancer when gathering bootstrap log bundles.
8483
func (*Provider) PublicGatherEndpoint() clusterapi.GatherEndpoint { return clusterapi.APILoadBalancer }
8584

86-
// PreProvision is called before provisioning using CAPI controllers has begun.
87-
func (p *Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionInput) error {
88-
installConfig := in.InstallConfig.Config
89-
platform := installConfig.Platform.Azure
90-
p.ResourceGroupName = platform.ClusterResourceGroupName(in.InfraID)
91-
92-
userTags := platform.UserTags
93-
tags := make(map[string]*string, len(userTags)+1)
94-
tags[fmt.Sprintf("kubernetes.io_cluster.%s", in.InfraID)] = ptr.To("owned")
95-
for k, v := range userTags {
96-
tags[k] = ptr.To(v)
97-
}
98-
p.Tags = tags
99-
100-
return nil
101-
}
102-
10385
// InfraReady is called once the installer infrastructure is ready.
10486
func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput) error {
10587
session, err := in.InstallConfig.Azure.Session()
@@ -112,6 +94,15 @@ func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput
11294
subscriptionID := session.Credentials.SubscriptionID
11395
cloudConfiguration := session.CloudConfig
11496
tokenCredential := session.TokenCreds
97+
p.ResourceGroupName = platform.ClusterResourceGroupName(in.InfraID)
98+
99+
userTags := platform.UserTags
100+
tags := make(map[string]*string, len(userTags)+1)
101+
tags[fmt.Sprintf("kubernetes.io_cluster.%s", in.InfraID)] = ptr.To("owned")
102+
for k, v := range userTags {
103+
tags[k] = ptr.To(v)
104+
}
105+
p.Tags = tags
115106

116107
// Creating a dummy nsg for existing vnets installation to appease the ingress operator.
117108
if in.InstallConfig.Config.Azure.VirtualNetwork != "" {
@@ -192,13 +183,6 @@ func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput
192183
return fmt.Errorf("image length is not aligned on a 512 byte boundary")
193184
}
194185

195-
userTags := platform.UserTags
196-
tags := make(map[string]*string, len(userTags)+1)
197-
tags[fmt.Sprintf("kubernetes.io_cluster.%s", in.InfraID)] = ptr.To("owned")
198-
for k, v := range userTags {
199-
tags[k] = ptr.To(v)
200-
}
201-
202186
storageURL := fmt.Sprintf("https://%s.blob.%s", storageAccountName, session.Environment.StorageEndpointSuffix)
203187
blobURL := fmt.Sprintf("%s/%s/%s", storageURL, containerName, blobName)
204188

0 commit comments

Comments
 (0)