diff --git a/api/v1beta1/azureclustertemplate_webhook.go b/api/v1beta1/azureclustertemplate_webhook.go index a27ec3d35dd..c22347434bb 100644 --- a/api/v1beta1/azureclustertemplate_webhook.go +++ b/api/v1beta1/azureclustertemplate_webhook.go @@ -67,7 +67,7 @@ func (c *AzureClusterTemplate) ValidateUpdate(oldRaw runtime.Object) (admission. if len(allErrs) == 0 { return nil, nil } - return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureClusterTemplate").GroupKind(), c.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind(AzureClusterTemplateKind).GroupKind(), c.Name, allErrs) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. diff --git a/api/v1beta1/azuremachine_webhook.go b/api/v1beta1/azuremachine_webhook.go index aa16fed2d09..e828a487e9f 100644 --- a/api/v1beta1/azuremachine_webhook.go +++ b/api/v1beta1/azuremachine_webhook.go @@ -70,7 +70,7 @@ func (mw *azureMachineWebhook) ValidateCreate(ctx context.Context, obj runtime.O return nil, nil } - return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureMachine").GroupKind(), m.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind(AzureMachineKind).GroupKind(), m.Name, allErrs) } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. @@ -209,7 +209,7 @@ func (mw *azureMachineWebhook) ValidateUpdate(ctx context.Context, oldObj, newOb if len(allErrs) == 0 { return nil, nil } - return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureMachine").GroupKind(), m.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind(AzureMachineKind).GroupKind(), m.Name, allErrs) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. diff --git a/api/v1beta1/azuremachinetemplate_webhook.go b/api/v1beta1/azuremachinetemplate_webhook.go index bb0bcd5872f..cb4b43a7b0c 100644 --- a/api/v1beta1/azuremachinetemplate_webhook.go +++ b/api/v1beta1/azuremachinetemplate_webhook.go @@ -89,7 +89,7 @@ func (r *AzureMachineTemplate) ValidateCreate(ctx context.Context, obj runtime.O return nil, nil } - return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureMachineTemplate").GroupKind(), t.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind(AzureMachineTemplateKind).GroupKind(), t.Name, allErrs) } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. @@ -133,7 +133,7 @@ func (r *AzureMachineTemplate) ValidateUpdate(ctx context.Context, oldRaw runtim if len(allErrs) == 0 { return nil, nil } - return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureMachineTemplate").GroupKind(), t.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind(AzureMachineTemplateKind).GroupKind(), t.Name, allErrs) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. diff --git a/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go b/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go index f31ef754ba7..245d18113e1 100644 --- a/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go +++ b/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go @@ -176,7 +176,7 @@ func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateUpdate(ctx context. return nil, mcp.validateManagedControlPlaneTemplate(mcpw.Client) } - return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedControlPlaneTemplate").GroupKind(), mcp.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind(AzureManagedControlPlaneTemplateKind).GroupKind(), mcp.Name, allErrs) } // Validate the Azure Managed Control Plane Template and return an aggregate error. diff --git a/api/v1beta1/azuremanagedmachinepool_webhook.go b/api/v1beta1/azuremanagedmachinepool_webhook.go index fd06dec4986..1ee4244c61a 100644 --- a/api/v1beta1/azuremanagedmachinepool_webhook.go +++ b/api/v1beta1/azuremanagedmachinepool_webhook.go @@ -293,7 +293,7 @@ func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, ol } if len(allErrs) != 0 { - return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedMachinePool").GroupKind(), m.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind(AzureManagedMachinePoolKind).GroupKind(), m.Name, allErrs) } return nil, nil diff --git a/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go b/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go index 7789511f33d..d00a58c840e 100644 --- a/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go +++ b/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go @@ -270,7 +270,7 @@ func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateUpdate(ctx context.Co if len(allErrs) == 0 { return nil, nil } - return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedMachinePoolTemplate").GroupKind(), mp.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind(AzureManagedMachinePoolTemplateKind).GroupKind(), mp.Name, allErrs) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. diff --git a/api/v1beta1/consts.go b/api/v1beta1/consts.go index 07aeb89f5a3..590da87c172 100644 --- a/api/v1beta1/consts.go +++ b/api/v1beta1/consts.go @@ -159,17 +159,32 @@ const ( OwnedByClusterLabelKey = NameAzureProviderPrefix + string(ResourceLifecycleOwned) ) +const ( + // AzureNetworkPluginName is the name of the Azure network plugin. + AzureNetworkPluginName = "azure" +) + const ( // AzureClusterKind indicates the kind of an AzureCluster. AzureClusterKind = "AzureCluster" + // AzureClusterTemplateKind indicates the kind of an AzureClusterTemplate. + AzureClusterTemplateKind = "AzureClusterTemplate" + // AzureMachineKind indicates the kind of an AzureMachine. + AzureMachineKind = "AzureMachine" + // AzureMachineTemplateKind indicates the kind of an AzureMachineTemplate. + AzureMachineTemplateKind = "AzureMachineTemplate" // AzureMachinePoolKind indicates the kind of an AzureMachinePool. AzureMachinePoolKind = "AzureMachinePool" + // AzureManagedMachinePoolKind indicates the kind of an AzureManagedMachinePool. + AzureManagedMachinePoolKind = "AzureManagedMachinePool" // AzureManagedClusterKind indicates the kind of an AzureManagedCluster. AzureManagedClusterKind = "AzureManagedCluster" // AzureManagedControlPlaneKind indicates the kind of an AzureManagedControlPlane. AzureManagedControlPlaneKind = "AzureManagedControlPlane" + // AzureManagedControlPlaneTemplateKind indicates the kind of an AzureManagedControlPlaneTemplate. + AzureManagedControlPlaneTemplateKind = "AzureManagedControlPlaneTemplate" + // AzureManagedMachinePoolTemplateKind indicates the kind of an AzureManagedMachinePoolTemplate. + AzureManagedMachinePoolTemplateKind = "AzureManagedMachinePoolTemplate" // AzureClusterIdentityKind indicates the kind of an AzureClusterIdentity. AzureClusterIdentityKind = "AzureClusterIdentity" - // AzureNetworkPluginName is the name of the Azure network plugin. - AzureNetworkPluginName = "azure" ) diff --git a/azure/scope/managedcontrolplane.go b/azure/scope/managedcontrolplane.go index ad0ca377fda..3e2a4a5f5fb 100644 --- a/azure/scope/managedcontrolplane.go +++ b/azure/scope/managedcontrolplane.go @@ -701,7 +701,7 @@ func (s *ManagedControlPlaneScope) MakeClusterCA() *corev1.Secret { Name: secret.Name(s.Cluster.Name, secret.ClusterCA), Namespace: s.Cluster.Namespace, OwnerReferences: []metav1.OwnerReference{ - *metav1.NewControllerRef(s.ControlPlane, infrav1.GroupVersion.WithKind("AzureManagedControlPlane")), + *metav1.NewControllerRef(s.ControlPlane, infrav1.GroupVersion.WithKind(infrav1.AzureManagedControlPlaneKind)), }, }, }