Skip to content

Commit

Permalink
Merge pull request #4287 from willie-yao/clusterclass-aks-followup
Browse files Browse the repository at this point in the history
Add missing kind constants for API
  • Loading branch information
k8s-ci-robot authored Nov 17, 2023
2 parents 07fde52 + 337ce25 commit 6102da4
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/v1beta1/azureclustertemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/azuremachine_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/azuremachinetemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/azuremanagedmachinepool_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/azuremanagedmachinepooltemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 17 additions & 2 deletions api/v1beta1/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
2 changes: 1 addition & 1 deletion azure/scope/managedcontrolplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
},
},
}
Expand Down

0 comments on commit 6102da4

Please sign in to comment.