From 90b76d3a9a2e5b8bd6ccdf39612fb84db02f1540 Mon Sep 17 00:00:00 2001 From: laksh keswani <40606132+lakshkeswani@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:44:54 -0400 Subject: [PATCH] Refactored codebase to use camel case for spec parameter in field.NewPath method (#4878) * refactored field newPath method to use camel case for spec * reformated code * resolved comments --- api/v1beta1/azurecluster_validation.go | 4 +- api/v1beta1/azurecluster_webhook.go | 18 +- api/v1beta1/azuremachine_validation.go | 8 +- api/v1beta1/azuremachine_webhook.go | 22 +-- api/v1beta1/azuremachinetemplate_webhook.go | 2 +- .../azuremanagedcontrolplane_webhook.go | 154 +++++++++--------- .../azuremanagedcontrolplane_webhook_test.go | 32 ++-- ...zuremanagedcontrolplanetemplate_webhook.go | 50 +++--- .../azuremanagedmachinepool_webhook.go | 58 +++---- ...azuremanagedmachinepooltemplate_webhook.go | 54 +++--- exp/api/v1beta1/azuremachinepool_webhook.go | 6 +- util/webhook/validator_test.go | 16 +- 12 files changed, 212 insertions(+), 212 deletions(-) diff --git a/api/v1beta1/azurecluster_validation.go b/api/v1beta1/azurecluster_validation.go index a079e6ea855..6cd04b6a04a 100644 --- a/api/v1beta1/azurecluster_validation.go +++ b/api/v1beta1/azurecluster_validation.go @@ -101,7 +101,7 @@ func (c *AzureCluster) validateClusterSpec(old *AzureCluster) field.ErrorList { // If ClusterSpec has non-nil ExtendedLocation field but not enable EdgeZone feature gate flag, ClusterSpec validation failed. if !feature.Gates.Enabled(feature.EdgeZone) && c.Spec.ExtendedLocation != nil { - allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "ExtendedLocation"), "can be set only if the EdgeZone feature flag is enabled")) + allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "extendedLocation"), "can be set only if the EdgeZone feature flag is enabled")) } if err := validateBastionSpec(c.Spec.BastionSpec, field.NewPath("spec").Child("azureBastion").Child("bastionSpec")); err != nil { @@ -123,7 +123,7 @@ func (c *AzureCluster) validateClusterName() field.ErrorList { fmt.Sprintf("Cluster Name longer than allowed length of %d characters", clusterNameMaxLength))) } if success, _ := regexp.MatchString(clusterNameRegex, c.Name); !success { - allErrs = append(allErrs, field.Invalid(field.NewPath("metadata").Child("Name"), c.Name, + allErrs = append(allErrs, field.Invalid(field.NewPath("metadata").Child("name"), c.Name, fmt.Sprintf("Cluster Name doesn't match regex %s, can contain only lowercase alphanumeric characters and '-', must start/end with an alphanumeric character", clusterNameRegex))) } diff --git a/api/v1beta1/azurecluster_webhook.go b/api/v1beta1/azurecluster_webhook.go index 49cc7c7fe00..8dc51a0bcfd 100644 --- a/api/v1beta1/azurecluster_webhook.go +++ b/api/v1beta1/azurecluster_webhook.go @@ -57,21 +57,21 @@ func (c *AzureCluster) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings old := oldRaw.(*AzureCluster) if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "ResourceGroup"), + field.NewPath("spec", "resourceGroup"), old.Spec.ResourceGroup, c.Spec.ResourceGroup); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "SubscriptionID"), + field.NewPath("spec", "subscriptionID"), old.Spec.SubscriptionID, c.Spec.SubscriptionID); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Location"), + field.NewPath("spec", "location"), old.Spec.Location, c.Spec.Location); err != nil { allErrs = append(allErrs, err) @@ -79,14 +79,14 @@ func (c *AzureCluster) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings if old.Spec.ControlPlaneEndpoint.Host != "" && c.Spec.ControlPlaneEndpoint.Host != old.Spec.ControlPlaneEndpoint.Host { allErrs = append(allErrs, - field.Invalid(field.NewPath("spec", "ControlPlaneEndpoint", "Host"), + field.Invalid(field.NewPath("spec", "controlPlaneEndpoint", "host"), c.Spec.ControlPlaneEndpoint.Host, "field is immutable"), ) } if old.Spec.ControlPlaneEndpoint.Port != 0 && c.Spec.ControlPlaneEndpoint.Port != old.Spec.ControlPlaneEndpoint.Port { allErrs = append(allErrs, - field.Invalid(field.NewPath("spec", "ControlPlaneEndpoint", "Port"), + field.Invalid(field.NewPath("spec", "controlPlaneEndpoint", "port"), c.Spec.ControlPlaneEndpoint.Port, "field is immutable"), ) } @@ -102,14 +102,14 @@ func (c *AzureCluster) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings // if it's still not equal, return error. if !reflect.DeepEqual(c.Spec.AzureEnvironment, old.Spec.AzureEnvironment) { allErrs = append(allErrs, - field.Invalid(field.NewPath("spec", "AzureEnvironment"), + field.Invalid(field.NewPath("spec", "azureEnvironment"), c.Spec.AzureEnvironment, "field is immutable"), ) } } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "NetworkSpec", "PrivateDNSZoneName"), + field.NewPath("spec", "networkSpec", "privateDNSZoneName"), old.Spec.NetworkSpec.PrivateDNSZoneName, c.Spec.NetworkSpec.PrivateDNSZoneName); err != nil { allErrs = append(allErrs, err) @@ -118,13 +118,13 @@ func (c *AzureCluster) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings // Allow enabling azure bastion but avoid disabling it. if old.Spec.BastionSpec.AzureBastion != nil && !reflect.DeepEqual(old.Spec.BastionSpec.AzureBastion, c.Spec.BastionSpec.AzureBastion) { allErrs = append(allErrs, - field.Invalid(field.NewPath("spec", "BastionSpec", "AzureBastion"), + field.Invalid(field.NewPath("spec", "bastionSpec", "azureBastion"), c.Spec.BastionSpec.AzureBastion, "azure bastion cannot be removed from a cluster"), ) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "NetworkSpec", "ControlPlaneOutboundLB"), + field.NewPath("spec", "networkSpec", "controlPlaneOutboundLB"), old.Spec.NetworkSpec.ControlPlaneOutboundLB, c.Spec.NetworkSpec.ControlPlaneOutboundLB); err != nil { allErrs = append(allErrs, err) diff --git a/api/v1beta1/azuremachine_validation.go b/api/v1beta1/azuremachine_validation.go index 972e9816b3c..9dd9d347a05 100644 --- a/api/v1beta1/azuremachine_validation.go +++ b/api/v1beta1/azuremachine_validation.go @@ -162,14 +162,14 @@ func ValidateSystemAssignedIdentityRole(identityType VMIdentity, roleAssignmentN } if identityType == VMIdentitySystemAssigned { if role.DefinitionID == "" { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "SystemAssignedIdentityRole", "DefinitionID"), role.DefinitionID, "the definitionID field cannot be empty")) + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "systemAssignedIdentityRole", "definitionID"), role.DefinitionID, "the definitionID field cannot be empty")) } if role.Scope == "" { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "SystemAssignedIdentityRole", "Scope"), role.Scope, "the scope field cannot be empty")) + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "systemAssignedIdentityRole", "scope"), role.Scope, "the scope field cannot be empty")) } } if identityType != VMIdentitySystemAssigned && role != nil { - allErrs = append(allErrs, field.Forbidden(field.NewPath("Spec", "Role"), "systemAssignedIdentityRole can only be set when identity is set to SystemAssigned")) + allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "role"), "systemAssignedIdentityRole can only be set when identity is set to SystemAssigned")) } return allErrs } @@ -482,7 +482,7 @@ func ValidateVMExtensions(disableExtensionOperations *bool, vmExtensions []VMExt allErrs := field.ErrorList{} if ptr.Deref(disableExtensionOperations, false) && len(vmExtensions) > 0 { - allErrs = append(allErrs, field.Forbidden(field.NewPath("AzureMachineTemplate", "spec", "template", "spec", "VMExtensions"), "VMExtensions must be empty when DisableExtensionOperations is true")) + allErrs = append(allErrs, field.Forbidden(field.NewPath("AzureMachineTemplate", "spec", "template", "spec", "vmExtensions"), "VMExtensions must be empty when DisableExtensionOperations is true")) } return allErrs diff --git a/api/v1beta1/azuremachine_webhook.go b/api/v1beta1/azuremachine_webhook.go index c5edbab1cdc..3953dcad3e3 100644 --- a/api/v1beta1/azuremachine_webhook.go +++ b/api/v1beta1/azuremachine_webhook.go @@ -86,70 +86,70 @@ func (mw *azureMachineWebhook) ValidateUpdate(ctx context.Context, oldObj, newOb } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Image"), + field.NewPath("spec", "image"), old.Spec.Image, m.Spec.Image); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Identity"), + field.NewPath("spec", "identity"), old.Spec.Identity, m.Spec.Identity); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "SystemAssignedIdentityRole"), + field.NewPath("spec", "systemAssignedIdentityRole"), old.Spec.SystemAssignedIdentityRole, m.Spec.SystemAssignedIdentityRole); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "UserAssignedIdentities"), + field.NewPath("spec", "userAssignedIdentities"), old.Spec.UserAssignedIdentities, m.Spec.UserAssignedIdentities); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "RoleAssignmentName"), + field.NewPath("spec", "roleAssignmentName"), old.Spec.RoleAssignmentName, m.Spec.RoleAssignmentName); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "OSDisk"), + field.NewPath("spec", "osDisk"), old.Spec.OSDisk, m.Spec.OSDisk); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "DataDisks"), + field.NewPath("spec", "dataDisks"), old.Spec.DataDisks, m.Spec.DataDisks); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "SSHPublicKey"), + field.NewPath("spec", "sshPublicKey"), old.Spec.SSHPublicKey, m.Spec.SSHPublicKey); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "AllocatePublicIP"), + field.NewPath("spec", "allocatePublicIP"), old.Spec.AllocatePublicIP, m.Spec.AllocatePublicIP); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "EnableIPForwarding"), + field.NewPath("spec", "enableIPForwarding"), old.Spec.EnableIPForwarding, m.Spec.EnableIPForwarding); err != nil { allErrs = append(allErrs, err) @@ -181,7 +181,7 @@ func (mw *azureMachineWebhook) ValidateUpdate(ctx context.Context, oldObj, newOb if old.Spec.Diagnostics != nil { if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Diagnostics"), + field.NewPath("spec", "diagnostics"), old.Spec.Diagnostics, m.Spec.Diagnostics); err != nil { allErrs = append(allErrs, err) diff --git a/api/v1beta1/azuremachinetemplate_webhook.go b/api/v1beta1/azuremachinetemplate_webhook.go index 01cde89f300..9130f92ac19 100644 --- a/api/v1beta1/azuremachinetemplate_webhook.go +++ b/api/v1beta1/azuremachinetemplate_webhook.go @@ -87,7 +87,7 @@ func (r *AzureMachineTemplate) ValidateCreate(ctx context.Context, obj runtime.O } if ptr.Deref(r.Spec.Template.Spec.DisableExtensionOperations, false) && len(r.Spec.Template.Spec.VMExtensions) > 0 { - allErrs = append(allErrs, field.Forbidden(field.NewPath("AzureMachineTemplate", "spec", "template", "spec", "VMExtensions"), "VMExtensions must be empty when DisableExtensionOperations is true")) + allErrs = append(allErrs, field.Forbidden(field.NewPath("AzureMachineTemplate", "spec", "template", "spec", "vmExtensions"), "VMExtensions must be empty when DisableExtensionOperations is true")) } if len(allErrs) == 0 { diff --git a/api/v1beta1/azuremanagedcontrolplane_webhook.go b/api/v1beta1/azuremanagedcontrolplane_webhook.go index 238e3e098bb..a0190288ae6 100644 --- a/api/v1beta1/azuremanagedcontrolplane_webhook.go +++ b/api/v1beta1/azuremanagedcontrolplane_webhook.go @@ -139,18 +139,18 @@ func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, o old interface{} new interface{} }{ - {field.NewPath("Spec", "SubscriptionID"), old.Spec.SubscriptionID, m.Spec.SubscriptionID}, - {field.NewPath("Spec", "ResourceGroupName"), old.Spec.ResourceGroupName, m.Spec.ResourceGroupName}, - {field.NewPath("Spec", "NodeResourceGroupName"), old.Spec.NodeResourceGroupName, m.Spec.NodeResourceGroupName}, - {field.NewPath("Spec", "Location"), old.Spec.Location, m.Spec.Location}, - {field.NewPath("Spec", "SSHPublicKey"), old.Spec.SSHPublicKey, m.Spec.SSHPublicKey}, - {field.NewPath("Spec", "DNSServiceIP"), old.Spec.DNSServiceIP, m.Spec.DNSServiceIP}, - {field.NewPath("Spec", "NetworkPlugin"), old.Spec.NetworkPlugin, m.Spec.NetworkPlugin}, - {field.NewPath("Spec", "NetworkPolicy"), old.Spec.NetworkPolicy, m.Spec.NetworkPolicy}, - {field.NewPath("Spec", "NetworkDataplane"), old.Spec.NetworkDataplane, m.Spec.NetworkDataplane}, - {field.NewPath("Spec", "LoadBalancerSKU"), old.Spec.LoadBalancerSKU, m.Spec.LoadBalancerSKU}, - {field.NewPath("Spec", "HTTPProxyConfig"), old.Spec.HTTPProxyConfig, m.Spec.HTTPProxyConfig}, - {field.NewPath("Spec", "AzureEnvironment"), old.Spec.AzureEnvironment, m.Spec.AzureEnvironment}, + {field.NewPath("spec", "subscriptionID"), old.Spec.SubscriptionID, m.Spec.SubscriptionID}, + {field.NewPath("spec", "resourceGroupName"), old.Spec.ResourceGroupName, m.Spec.ResourceGroupName}, + {field.NewPath("spec", "nodeResourceGroupName"), old.Spec.NodeResourceGroupName, m.Spec.NodeResourceGroupName}, + {field.NewPath("spec", "location"), old.Spec.Location, m.Spec.Location}, + {field.NewPath("spec", "sshPublicKey"), old.Spec.SSHPublicKey, m.Spec.SSHPublicKey}, + {field.NewPath("spec", "dnsServiceIP"), old.Spec.DNSServiceIP, m.Spec.DNSServiceIP}, + {field.NewPath("spec", "networkPlugin"), old.Spec.NetworkPlugin, m.Spec.NetworkPlugin}, + {field.NewPath("spec", "networkPolicy"), old.Spec.NetworkPolicy, m.Spec.NetworkPolicy}, + {field.NewPath("spec", "networkDataplane"), old.Spec.NetworkDataplane, m.Spec.NetworkDataplane}, + {field.NewPath("spec", "loadBalancerSKU"), old.Spec.LoadBalancerSKU, m.Spec.LoadBalancerSKU}, + {field.NewPath("spec", "httpProxyConfig"), old.Spec.HTTPProxyConfig, m.Spec.HTTPProxyConfig}, + {field.NewPath("spec", "azureEnvironment"), old.Spec.AzureEnvironment, m.Spec.AzureEnvironment}, } for _, f := range immutableFields { @@ -170,7 +170,7 @@ func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, o oldDNSPrefix = ptr.To(old.Name) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "DNSPrefix"), + field.NewPath("spec", "dnsPrefix"), oldDNSPrefix, m.Spec.DNSPrefix, ); err != nil { @@ -182,7 +182,7 @@ func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, o // Updating outboundType after cluster creation (PREVIEW) // https://learn.microsoft.com/en-us/azure/aks/egress-outboundtype#updating-outboundtype-after-cluster-creation-preview if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "OutboundType"), + field.NewPath("spec", "outboundType"), old.Spec.OutboundType, m.Spec.OutboundType); err != nil { allErrs = append(allErrs, err) @@ -262,11 +262,11 @@ func (m *AzureManagedControlPlane) Validate(cli client.Client) error { allErrs = append(allErrs, validateVersion( m.Spec.Version, - field.NewPath("Spec").Child("Version"))...) + field.NewPath("spec").Child("version"))...) allErrs = append(allErrs, validateLoadBalancerProfile( m.Spec.LoadBalancerProfile, - field.NewPath("Spec").Child("LoadBalancerProfile"))...) + field.NewPath("spec").Child("loadBalancerProfile"))...) allErrs = append(allErrs, validateManagedClusterNetwork( cli, @@ -274,25 +274,25 @@ func (m *AzureManagedControlPlane) Validate(cli client.Client) error { m.Namespace, m.Spec.DNSServiceIP, m.Spec.VirtualNetwork.Subnet, - field.NewPath("Spec"))...) + field.NewPath("spec"))...) - allErrs = append(allErrs, validateName(m.Name, field.NewPath("Name"))...) + allErrs = append(allErrs, validateName(m.Name, field.NewPath("name"))...) - allErrs = append(allErrs, validateAutoScalerProfile(m.Spec.AutoScalerProfile, field.NewPath("spec").Child("AutoScalerProfile"))...) + allErrs = append(allErrs, validateAutoScalerProfile(m.Spec.AutoScalerProfile, field.NewPath("spec").Child("autoScalerProfile"))...) - allErrs = append(allErrs, validateAKSExtensions(m.Spec.Extensions, field.NewPath("spec").Child("AKSExtensions"))...) + allErrs = append(allErrs, validateAKSExtensions(m.Spec.Extensions, field.NewPath("spec").Child("aksExtensions"))...) allErrs = append(allErrs, m.Spec.AzureManagedControlPlaneClassSpec.validateSecurityProfile()...) - allErrs = append(allErrs, validateNetworkPolicy(m.Spec.NetworkPolicy, m.Spec.NetworkDataplane, field.NewPath("spec").Child("NetworkPolicy"))...) + allErrs = append(allErrs, validateNetworkPolicy(m.Spec.NetworkPolicy, m.Spec.NetworkDataplane, field.NewPath("spec").Child("networkPolicy"))...) - allErrs = append(allErrs, validateNetworkDataplane(m.Spec.NetworkDataplane, m.Spec.NetworkPolicy, m.Spec.NetworkPluginMode, field.NewPath("spec").Child("NetworkDataplane"))...) + allErrs = append(allErrs, validateNetworkDataplane(m.Spec.NetworkDataplane, m.Spec.NetworkPolicy, m.Spec.NetworkPluginMode, field.NewPath("spec").Child("networkDataplane"))...) - allErrs = append(allErrs, validateAPIServerAccessProfile(m.Spec.APIServerAccessProfile, field.NewPath("spec").Child("APIServerAccessProfile"))...) + allErrs = append(allErrs, validateAPIServerAccessProfile(m.Spec.APIServerAccessProfile, field.NewPath("spec").Child("apiServerAccessProfile"))...) - allErrs = append(allErrs, validateAMCPVirtualNetwork(m.Spec.VirtualNetwork, field.NewPath("spec").Child("VirtualNetwork"))...) + allErrs = append(allErrs, validateAMCPVirtualNetwork(m.Spec.VirtualNetwork, field.NewPath("spec").Child("virtualNetwork"))...) - allErrs = append(allErrs, validateFleetsMember(m.Spec.FleetsMember, field.NewPath("spec").Child("FleetsMember"))...) + allErrs = append(allErrs, validateFleetsMember(m.Spec.FleetsMember, field.NewPath("spec").Child("fleetsMember"))...) return allErrs.ToAggregate() } @@ -312,7 +312,7 @@ func (m *AzureManagedControlPlane) validateDNSPrefix(_ client.Client) field.Erro return nil } allErrs := field.ErrorList{ - field.Invalid(field.NewPath("Spec", "DNSPrefix"), *m.Spec.DNSPrefix, "DNSPrefix is invalid, does not match regex: "+pattern), + field.Invalid(field.NewPath("spec", "dnsPrefix"), *m.Spec.DNSPrefix, "DNSPrefix is invalid, does not match regex: "+pattern), } return allErrs } @@ -334,7 +334,7 @@ func (m *AzureManagedControlPlaneClassSpec) validateAzureKeyVaultKms() field.Err if m.SecurityProfile != nil && m.SecurityProfile.AzureKeyVaultKms != nil { if !m.isUserManagedIdentityEnabled() { allErrs := field.ErrorList{ - field.Invalid(field.NewPath("Spec", "SecurityProfile", "AzureKeyVaultKms", "KeyVaultResourceID"), + field.Invalid(field.NewPath("spec", "securityProfile", "azureKeyVaultKms", "keyVaultResourceID"), m.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID, "Spec.SecurityProfile.AzureKeyVaultKms can be set only when Spec.Identity.Type is UserAssigned"), } @@ -344,7 +344,7 @@ func (m *AzureManagedControlPlaneClassSpec) validateAzureKeyVaultKms() field.Err keyVaultResourceID := ptr.Deref(m.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID, "") if keyVaultNetworkAccess == KeyVaultNetworkAccessTypesPrivate && keyVaultResourceID == "" { allErrs := field.ErrorList{ - field.Invalid(field.NewPath("Spec", "SecurityProfile", "AzureKeyVaultKms", "KeyVaultResourceID"), + field.Invalid(field.NewPath("spec", "securityProfile", "azureKeyVaultKms", "keyVaultResourceID"), m.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID, "Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID cannot be empty when Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultNetworkAccess is Private"), } @@ -352,7 +352,7 @@ func (m *AzureManagedControlPlaneClassSpec) validateAzureKeyVaultKms() field.Err } if keyVaultNetworkAccess == KeyVaultNetworkAccessTypesPublic && keyVaultResourceID != "" { allErrs := field.ErrorList{ - field.Invalid(field.NewPath("Spec", "SecurityProfile", "AzureKeyVaultKms", "KeyVaultResourceID"), m.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID, + field.Invalid(field.NewPath("spec", "securityProfile", "azureKeyVaultKms", "keyVaultResourceID"), m.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID, "Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID should be empty when Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultNetworkAccess is Public"), } return allErrs @@ -365,7 +365,7 @@ func (m *AzureManagedControlPlaneClassSpec) validateAzureKeyVaultKms() field.Err func (m *AzureManagedControlPlaneClassSpec) validateWorkloadIdentity() field.ErrorList { if m.SecurityProfile != nil && m.SecurityProfile.WorkloadIdentity != nil && !m.isOIDCEnabled() { allErrs := field.ErrorList{ - field.Invalid(field.NewPath("Spec", "SecurityProfile", "WorkloadIdentity"), m.SecurityProfile.WorkloadIdentity, + field.Invalid(field.NewPath("spec", "securityProfile", "workloadIdentity"), m.SecurityProfile.WorkloadIdentity, "Spec.SecurityProfile.WorkloadIdentity cannot be enabled when Spec.OIDCIssuerProfile is disabled"), } return allErrs @@ -377,7 +377,7 @@ func (m *AzureManagedControlPlaneClassSpec) validateWorkloadIdentity() field.Err func (m *AzureManagedControlPlane) validateDisableLocalAccounts(_ client.Client) field.ErrorList { if m.Spec.DisableLocalAccounts != nil && m.Spec.AADProfile == nil { return field.ErrorList{ - field.Invalid(field.NewPath("Spec", "DisableLocalAccounts"), *m.Spec.DisableLocalAccounts, "DisableLocalAccounts should be set only for AAD enabled clusters"), + field.Invalid(field.NewPath("spec", "disableLocalAccounts"), *m.Spec.DisableLocalAccounts, "DisableLocalAccounts should be set only for AAD enabled clusters"), } } return nil @@ -555,7 +555,7 @@ func validateManagedClusterNetwork(cli client.Client, labels map[string]string, } if err := cli.Get(ctx, key, ownerCluster); err != nil { - allErrs = append(allErrs, field.InternalError(field.NewPath("Cluster", "Spec", "ClusterNetwork"), err)) + allErrs = append(allErrs, field.InternalError(field.NewPath("Cluster", "spec", "clusterNetwork"), err)) return allErrs } @@ -564,7 +564,7 @@ func validateManagedClusterNetwork(cli client.Client, labels map[string]string, // A user may provide zero or one CIDR blocks. If they provide an empty array, // we ignore it and use the default. AKS doesn't support > 1 Service/Pod CIDR. if len(clusterNetwork.Services.CIDRBlocks) > 1 { - allErrs = append(allErrs, field.TooMany(field.NewPath("Cluster", "Spec", "ClusterNetwork", "Services", "CIDRBlocks"), len(clusterNetwork.Services.CIDRBlocks), 1)) + allErrs = append(allErrs, field.TooMany(field.NewPath("Cluster", "spec", "clusterNetwork", "services", "cidrBlocks"), len(clusterNetwork.Services.CIDRBlocks), 1)) } if len(clusterNetwork.Services.CIDRBlocks) == 1 { serviceCIDR = clusterNetwork.Services.CIDRBlocks[0] @@ -574,34 +574,34 @@ func validateManagedClusterNetwork(cli client.Client, labels map[string]string, // A user may provide zero or one CIDR blocks. If they provide an empty array, // we ignore it and use the default. AKS doesn't support > 1 Service/Pod CIDR. if len(clusterNetwork.Pods.CIDRBlocks) > 1 { - allErrs = append(allErrs, field.TooMany(field.NewPath("Cluster", "Spec", "ClusterNetwork", "Pods", "CIDRBlocks"), len(clusterNetwork.Pods.CIDRBlocks), 1)) + allErrs = append(allErrs, field.TooMany(field.NewPath("Cluster", "spec", "clusterNetwork", "pods", "cidrBlocks"), len(clusterNetwork.Pods.CIDRBlocks), 1)) } } } if dnsServiceIP != nil { if serviceCIDR == "" { - allErrs = append(allErrs, field.Required(field.NewPath("Cluster", "Spec", "ClusterNetwork", "Services", "CIDRBlocks"), "service CIDR must be specified if specifying DNSServiceIP")) + allErrs = append(allErrs, field.Required(field.NewPath("Cluster", "spec", "clusterNetwork", "services", "cidrBlocks"), "service CIDR must be specified if specifying DNSServiceIP")) } _, cidr, err := net.ParseCIDR(serviceCIDR) if err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath("Cluster", "Spec", "ClusterNetwork", "Services", "CIDRBlocks"), serviceCIDR, fmt.Sprintf("failed to parse cluster service cidr: %v", err))) + allErrs = append(allErrs, field.Invalid(field.NewPath("Cluster", "spec", "clusterNetwork", "services", "cidrBlocks"), serviceCIDR, fmt.Sprintf("failed to parse cluster service cidr: %v", err))) } dnsIP := net.ParseIP(*dnsServiceIP) if dnsIP == nil { // dnsIP will be nil if the string is not a valid IP - allErrs = append(allErrs, field.Invalid(field.NewPath("Cluster", "Spec", "ClusterNetwork", "Services", "DNSServiceIP"), *dnsServiceIP, "must be a valid IP address")) + allErrs = append(allErrs, field.Invalid(field.NewPath("Cluster", "spec", "clusterNetwork", "services", "dnsServiceIP"), *dnsServiceIP, "must be a valid IP address")) } if dnsIP != nil && !cidr.Contains(dnsIP) { - allErrs = append(allErrs, field.Invalid(field.NewPath("Cluster", "Spec", "ClusterNetwork", "Services", "CIDRBlocks"), serviceCIDR, "DNSServiceIP must reside within the associated cluster serviceCIDR")) + allErrs = append(allErrs, field.Invalid(field.NewPath("Cluster", "spec", "clusterNetwork", "services", "cidrBlocks"), serviceCIDR, "DNSServiceIP must reside within the associated cluster serviceCIDR")) } // AKS only supports .10 as the last octet for the DNSServiceIP. // Refer to: https://learn.microsoft.com/en-us/azure/aks/configure-kubenet#create-an-aks-cluster-with-system-assigned-managed-identities targetSuffix := ".10" if dnsIP != nil && !strings.HasSuffix(dnsIP.String(), targetSuffix) { - allErrs = append(allErrs, field.Invalid(field.NewPath("Cluster", "Spec", "ClusterNetwork", "Services", "DNSServiceIP"), *dnsServiceIP, fmt.Sprintf("must end with %q", targetSuffix))) + allErrs = append(allErrs, field.Invalid(field.NewPath("Cluster", "spec", "clusterNetwork", "services", "dnsServiceIP"), *dnsServiceIP, fmt.Sprintf("must end with %q", targetSuffix))) } } @@ -633,14 +633,14 @@ func (m *AzureManagedControlPlane) validateAutoUpgradeProfile(old *AzureManagedC func (m *AzureManagedControlPlane) validateK8sVersionUpdate(old *AzureManagedControlPlane) field.ErrorList { var allErrs field.ErrorList if hv := versions.GetHigherK8sVersion(m.Spec.Version, old.Spec.Version); hv != m.Spec.Version { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "Version"), + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "version"), m.Spec.Version, "field version cannot be downgraded"), ) } if old.Status.AutoUpgradeVersion != "" && m.Spec.Version != old.Spec.Version { if hv := versions.GetHigherK8sVersion(m.Spec.Version, old.Status.AutoUpgradeVersion); hv != m.Spec.Version { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "Version"), + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "version"), m.Spec.Version, "version is auto-upgraded to "+old.Status.AutoUpgradeVersion+", cannot be downgraded"), ) } @@ -675,7 +675,7 @@ func (m *AzureManagedControlPlane) validateAPIServerAccessProfileUpdate(old *Azu if !reflect.DeepEqual(newAPIServerAccessProfileNormalized, oldAPIServerAccessProfileNormalized) { allErrs = append(allErrs, - field.Invalid(field.NewPath("Spec", "APIServerAccessProfile"), + field.Invalid(field.NewPath("spec", "apiServerAccessProfile"), m.Spec.APIServerAccessProfile, "fields (except for AuthorizedIPRanges) are immutable"), ) } @@ -694,7 +694,7 @@ func (m *AzureManagedControlPlane) validateAddonProfilesUpdate(old *AzureManaged for i, addonProfile := range old.Spec.AddonProfiles { if _, ok := newAddonProfileMap[addonProfile.Name]; !ok { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "AddonProfiles"), + field.NewPath("spec", "addonProfiles"), m.Spec.AddonProfiles, fmt.Sprintf("cannot remove addonProfile %s, To disable this AddonProfile, update Spec.AddonProfiles[%v].Enabled to false", addonProfile.Name, i))) } @@ -709,7 +709,7 @@ func (m *AzureManagedControlPlane) validateVirtualNetworkUpdate(old *AzureManage if old.Spec.VirtualNetwork.Name != m.Spec.VirtualNetwork.Name { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "VirtualNetwork.Name"), + field.NewPath("spec", "virtualNetwork", "name"), m.Spec.VirtualNetwork.Name, "Virtual Network Name is immutable")) } @@ -717,7 +717,7 @@ func (m *AzureManagedControlPlane) validateVirtualNetworkUpdate(old *AzureManage if old.Spec.VirtualNetwork.CIDRBlock != m.Spec.VirtualNetwork.CIDRBlock { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "VirtualNetwork.CIDRBlock"), + field.NewPath("spec", "virtualNetwork", "cidrBlock"), m.Spec.VirtualNetwork.CIDRBlock, "Virtual Network CIDRBlock is immutable")) } @@ -725,7 +725,7 @@ func (m *AzureManagedControlPlane) validateVirtualNetworkUpdate(old *AzureManage if old.Spec.VirtualNetwork.Subnet.Name != m.Spec.VirtualNetwork.Subnet.Name { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "VirtualNetwork.Subnet.Name"), + field.NewPath("spec", "virtualNetwork", "subnet", "name"), m.Spec.VirtualNetwork.Subnet.Name, "Subnet Name is immutable")) } @@ -737,7 +737,7 @@ func (m *AzureManagedControlPlane) validateVirtualNetworkUpdate(old *AzureManage if old.Spec.VirtualNetwork.Subnet.CIDRBlock != m.Spec.VirtualNetwork.Subnet.CIDRBlock { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "VirtualNetwork.Subnet.CIDRBlock"), + field.NewPath("spec", "virtualNetwork", "subnet", "cidrBlock"), m.Spec.VirtualNetwork.Subnet.CIDRBlock, "Subnet CIDRBlock is immutable")) } @@ -745,7 +745,7 @@ func (m *AzureManagedControlPlane) validateVirtualNetworkUpdate(old *AzureManage if old.Spec.VirtualNetwork.ResourceGroup != m.Spec.VirtualNetwork.ResourceGroup { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "VirtualNetwork.ResourceGroup"), + field.NewPath("spec", "virtualNetwork", "resourceGroup"), m.Spec.VirtualNetwork.ResourceGroup, "Virtual Network Resource Group is immutable")) } @@ -759,7 +759,7 @@ func (m *AzureManagedControlPlane) validateNetworkPluginModeUpdate(old *AzureMan if ptr.Deref(old.Spec.NetworkPluginMode, "") != NetworkPluginModeOverlay && ptr.Deref(m.Spec.NetworkPluginMode, "") == NetworkPluginModeOverlay && old.Spec.NetworkPolicy != nil { - allErrs = append(allErrs, field.Forbidden(field.NewPath("Spec", "NetworkPluginMode"), fmt.Sprintf("%q NetworkPluginMode cannot be enabled when NetworkPolicy is set", NetworkPluginModeOverlay))) + allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "networkPluginMode"), fmt.Sprintf("%q NetworkPluginMode cannot be enabled when NetworkPolicy is set", NetworkPluginModeOverlay))) } return allErrs @@ -772,21 +772,21 @@ func (m *AzureManagedControlPlane) validateAADProfileUpdateAndLocalAccounts(old if m.Spec.AADProfile == nil { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "AADProfile"), + field.NewPath("spec", "aadProfile"), m.Spec.AADProfile, "field cannot be nil, cannot disable AADProfile")) } else { if !m.Spec.AADProfile.Managed && old.Spec.AADProfile.Managed { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "AADProfile.Managed"), + field.NewPath("spec", "aadProfile", "managed"), m.Spec.AADProfile.Managed, "cannot set AADProfile.Managed to false")) } if len(m.Spec.AADProfile.AdminGroupObjectIDs) == 0 { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "AADProfile.AdminGroupObjectIDs"), + field.NewPath("spec", "aadProfile", "adminGroupObjectIDs"), m.Spec.AADProfile.AdminGroupObjectIDs, "length of AADProfile.AdminGroupObjectIDs cannot be zero")) } @@ -798,7 +798,7 @@ func (m *AzureManagedControlPlane) validateAADProfileUpdateAndLocalAccounts(old m.Spec.AADProfile == nil { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "DisableLocalAccounts"), + field.NewPath("spec", "disableLocalAccounts"), m.Spec.DisableLocalAccounts, "DisableLocalAccounts can be set only for AAD enabled clusters")) } @@ -806,7 +806,7 @@ func (m *AzureManagedControlPlane) validateAADProfileUpdateAndLocalAccounts(old if old.Spec.DisableLocalAccounts != nil { // Prevent DisableLocalAccounts modification if it was already set to some value if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "DisableLocalAccounts"), + field.NewPath("spec", "disableLocalAccounts"), m.Spec.DisableLocalAccounts, old.Spec.DisableLocalAccounts, ); err != nil { @@ -842,7 +842,7 @@ func (m *AzureManagedControlPlaneClassSpec) validateAzureKeyVaultKmsUpdate(old * var allErrs field.ErrorList if old.SecurityProfile.AzureKeyVaultKms != nil { if m.SecurityProfile == nil || m.SecurityProfile.AzureKeyVaultKms == nil { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "SecurityProfile", "AzureKeyVaultKms"), + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "securityProfile", "azureKeyVaultKms"), nil, "cannot unset Spec.SecurityProfile.AzureKeyVaultKms profile to disable the profile please set Spec.SecurityProfile.AzureKeyVaultKms.Enabled to false")) return allErrs } @@ -855,7 +855,7 @@ func (m *AzureManagedControlPlaneClassSpec) validateWorkloadIdentityUpdate(old * var allErrs field.ErrorList if old.SecurityProfile.WorkloadIdentity != nil { if m.SecurityProfile == nil || m.SecurityProfile.WorkloadIdentity == nil { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "SecurityProfile", "WorkloadIdentity"), + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "securityProfile", "workloadIdentity"), nil, "cannot unset Spec.SecurityProfile.WorkloadIdentity, to disable workloadIdentity please set Spec.SecurityProfile.WorkloadIdentity.Enabled to false")) } } @@ -867,7 +867,7 @@ func (m *AzureManagedControlPlaneClassSpec) validateImageCleanerUpdate(old *Azur var allErrs field.ErrorList if old.SecurityProfile.ImageCleaner != nil { if m.SecurityProfile == nil || m.SecurityProfile.ImageCleaner == nil { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "SecurityProfile", "ImageCleaner"), + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "securityProfile", "imageCleaner"), nil, "cannot unset Spec.SecurityProfile.ImageCleaner, to disable imageCleaner please set Spec.SecurityProfile.ImageCleaner.Enabled to false")) } } @@ -879,7 +879,7 @@ func (m *AzureManagedControlPlaneClassSpec) validateDefender(old *AzureManagedCo var allErrs field.ErrorList if old.SecurityProfile.Defender != nil { if m.SecurityProfile == nil || m.SecurityProfile.Defender == nil { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "SecurityProfile", "Defender"), + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "securityProfile", "defender"), nil, "cannot unset Spec.SecurityProfile.Defender, to disable defender please set Spec.SecurityProfile.Defender.SecurityMonitoring.Enabled to false")) } } @@ -894,7 +894,7 @@ func (m *AzureManagedControlPlane) validateOIDCIssuerProfileUpdate(old *AzureMan !*m.Spec.OIDCIssuerProfile.Enabled && *old.Spec.OIDCIssuerProfile.Enabled { allErrs = append(allErrs, field.Forbidden( - field.NewPath("Spec", "OIDCIssuerProfile", "Enabled"), + field.NewPath("spec", "oidcIssuerProfile", "enabled"), "cannot be disabled", ), ) @@ -913,7 +913,7 @@ func (m *AzureManagedControlPlane) validateFleetsMemberUpdate(old *AzureManagedC if old.Spec.FleetsMember.Name != "" && old.Spec.FleetsMember.Name != m.Spec.FleetsMember.Name { allErrs = append(allErrs, field.Forbidden( - field.NewPath("Spec", "FleetsMember", "Name"), + field.NewPath("spec", "fleetsMember", "name"), "Name is immutable", ), ) @@ -940,7 +940,7 @@ func validateAKSExtensionsUpdate(old []AKSExtension, current []AKSExtension) fie if extension.Name != oldExtension.Name { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Extensions", fmt.Sprintf("[%d]", i), "Name"), + field.NewPath("spec", "extensions", fmt.Sprintf("[%d]", i), "name"), extension.Name, "field is immutable", ), @@ -949,7 +949,7 @@ func validateAKSExtensionsUpdate(old []AKSExtension, current []AKSExtension) fie if (oldExtension.ExtensionType != nil && extension.ExtensionType != nil) && *extension.ExtensionType != *oldExtension.ExtensionType { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Extensions", fmt.Sprintf("[%d]", i), "ExtensionType"), + field.NewPath("spec", "extensions", fmt.Sprintf("[%d]", i), "extensionType"), extension.ExtensionType, "field is immutable", ), @@ -958,7 +958,7 @@ func validateAKSExtensionsUpdate(old []AKSExtension, current []AKSExtension) fie if (extension.Plan != nil && oldExtension.Plan != nil) && *extension.Plan != *oldExtension.Plan { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Extensions", fmt.Sprintf("[%d]", i), "Plan"), + field.NewPath("spec", "extensions", fmt.Sprintf("[%d]", i), "plan"), extension.Plan, "field is immutable", ), @@ -967,7 +967,7 @@ func validateAKSExtensionsUpdate(old []AKSExtension, current []AKSExtension) fie if extension.Scope != oldExtension.Scope { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Extensions", fmt.Sprintf("[%d]", i), "Scope"), + field.NewPath("spec", "extensions", fmt.Sprintf("[%d]", i), "scope"), extension.Scope, "field is immutable", ), @@ -976,7 +976,7 @@ func validateAKSExtensionsUpdate(old []AKSExtension, current []AKSExtension) fie if (extension.ReleaseTrain != nil && oldExtension.ReleaseTrain != nil) && *extension.ReleaseTrain != *oldExtension.ReleaseTrain { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Extensions", fmt.Sprintf("[%d]", i), "ReleaseTrain"), + field.NewPath("spec", "extensions", fmt.Sprintf("[%d]", i), "releaseTrain"), extension.ReleaseTrain, "field is immutable", ), @@ -985,7 +985,7 @@ func validateAKSExtensionsUpdate(old []AKSExtension, current []AKSExtension) fie if (extension.Version != nil && oldExtension.Version != nil) && *extension.Version != *oldExtension.Version { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Extensions", fmt.Sprintf("[%d]", i), "Version"), + field.NewPath("spec", "extensions", fmt.Sprintf("[%d]", i), "version"), extension.Version, "field is immutable", ), @@ -994,7 +994,7 @@ func validateAKSExtensionsUpdate(old []AKSExtension, current []AKSExtension) fie if extension.Identity != oldExtension.Identity { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Extensions", fmt.Sprintf("[%d]", i), "Identity"), + field.NewPath("spec", "extensions", fmt.Sprintf("[%d]", i), "identity"), extension.Identity, "field is immutable", ), @@ -1104,7 +1104,7 @@ func validateAutoScalerProfile(autoScalerProfile *AutoScalerProfile, fldPath *fi if autoScalerProfile.MaxTotalUnreadyPercentage != nil { val, err := strconv.Atoi(*autoScalerProfile.MaxTotalUnreadyPercentage) if err != nil || val < 0 || val > 100 { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "AutoscalerProfile", "MaxTotalUnreadyPercentage"), autoScalerProfile.MaxTotalUnreadyPercentage, "invalid value")) + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "autoscalerProfile", "maxTotalUnreadyPercentage"), autoScalerProfile.MaxTotalUnreadyPercentage, "invalid value")) } } @@ -1112,7 +1112,7 @@ func validateAutoScalerProfile(autoScalerProfile *AutoScalerProfile, fldPath *fi allErrs = append(allErrs, errs...) } - if errs := validateIntegerStringGreaterThanZero(autoScalerProfile.OkTotalUnreadyCount, fldPath, "OkTotalUnreadyCount"); len(errs) > 0 { + if errs := validateIntegerStringGreaterThanZero(autoScalerProfile.OkTotalUnreadyCount, fldPath, "okTotalUnreadyCount"); len(errs) > 0 { allErrs = append(allErrs, errs...) } @@ -1120,7 +1120,7 @@ func validateAutoScalerProfile(autoScalerProfile *AutoScalerProfile, fldPath *fi allErrs = append(allErrs, errs...) } - if errs := validateScaleDownTime(autoScalerProfile.ScaleDownDelayAfterAdd, fldPath, "ScaleDownDelayAfterAdd"); len(errs) > 0 { + if errs := validateScaleDownTime(autoScalerProfile.ScaleDownDelayAfterAdd, fldPath, "scaleDownDelayAfterAdd"); len(errs) > 0 { allErrs = append(allErrs, errs...) } @@ -1128,22 +1128,22 @@ func validateAutoScalerProfile(autoScalerProfile *AutoScalerProfile, fldPath *fi allErrs = append(allErrs, errs...) } - if errs := validateScaleDownTime(autoScalerProfile.ScaleDownDelayAfterFailure, fldPath, "ScaleDownDelayAfterFailure"); len(errs) > 0 { + if errs := validateScaleDownTime(autoScalerProfile.ScaleDownDelayAfterFailure, fldPath, "scaleDownDelayAfterFailure"); len(errs) > 0 { allErrs = append(allErrs, errs...) } - if errs := validateScaleDownTime(autoScalerProfile.ScaleDownUnneededTime, fldPath, "ScaleDownUnneededTime"); len(errs) > 0 { + if errs := validateScaleDownTime(autoScalerProfile.ScaleDownUnneededTime, fldPath, "scaleDownUnneededTime"); len(errs) > 0 { allErrs = append(allErrs, errs...) } - if errs := validateScaleDownTime(autoScalerProfile.ScaleDownUnreadyTime, fldPath, "ScaleDownUnreadyTime"); len(errs) > 0 { + if errs := validateScaleDownTime(autoScalerProfile.ScaleDownUnreadyTime, fldPath, "scaleDownUnreadyTime"); len(errs) > 0 { allErrs = append(allErrs, errs...) } if autoScalerProfile.ScaleDownUtilizationThreshold != nil { val, err := strconv.ParseFloat(*autoScalerProfile.ScaleDownUtilizationThreshold, 32) if err != nil || val < 0 || val > 1 { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "AutoscalerProfile", "ScaleDownUtilizationThreshold"), autoScalerProfile.ScaleDownUtilizationThreshold, "invalid value")) + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "autoscalerProfile", "scaleDownUtilizationThreshold"), autoScalerProfile.ScaleDownUtilizationThreshold, "invalid value")) } } @@ -1227,11 +1227,11 @@ func (m *AzureManagedControlPlane) validateIdentity(_ client.Client) field.Error if m.Spec.Identity != nil { if m.Spec.Identity.Type == ManagedControlPlaneIdentityTypeUserAssigned { if m.Spec.Identity.UserAssignedIdentityResourceID == "" { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "Identity", "UserAssignedIdentityResourceID"), m.Spec.Identity.UserAssignedIdentityResourceID, "cannot be empty if Identity.Type is UserAssigned")) + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "identity", "userAssignedIdentityResourceID"), m.Spec.Identity.UserAssignedIdentityResourceID, "cannot be empty if Identity.Type is UserAssigned")) } } else { if m.Spec.Identity.UserAssignedIdentityResourceID != "" { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "Identity", "UserAssignedIdentityResourceID"), m.Spec.Identity.UserAssignedIdentityResourceID, "should be empty if Identity.Type is SystemAssigned")) + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "identity", "userAssignedIdentityResourceID"), m.Spec.Identity.UserAssignedIdentityResourceID, "should be empty if Identity.Type is SystemAssigned")) } } } @@ -1250,7 +1250,7 @@ func (m *AzureManagedControlPlane) validateNetworkPluginMode(_ client.Client) fi const kubenet = "kubenet" if ptr.Deref(m.Spec.NetworkPluginMode, "") == NetworkPluginModeOverlay && ptr.Deref(m.Spec.NetworkPlugin, "") == kubenet { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "NetworkPluginMode"), m.Spec.NetworkPluginMode, fmt.Sprintf("cannot be set to %q when NetworkPlugin is %q", NetworkPluginModeOverlay, kubenet))) + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "networkPluginMode"), m.Spec.NetworkPluginMode, fmt.Sprintf("cannot be set to %q when NetworkPlugin is %q", NetworkPluginModeOverlay, kubenet))) } if len(allErrs) > 0 { diff --git a/api/v1beta1/azuremanagedcontrolplane_webhook_test.go b/api/v1beta1/azuremanagedcontrolplane_webhook_test.go index fc465ee9533..bfa47bb3b7c 100644 --- a/api/v1beta1/azuremanagedcontrolplane_webhook_test.go +++ b/api/v1beta1/azuremanagedcontrolplane_webhook_test.go @@ -238,7 +238,7 @@ func TestValidateLoadBalancerProfile(t *testing.T) { }, expectedErr: field.Error{ Type: field.ErrorTypeInvalid, - Field: "spec.LoadBalancerProfile.ManagedOutboundIPs", + Field: "spec.loadBalancerProfile.ManagedOutboundIPs", BadValue: ptr.To(200), Detail: "value should be in between 1 and 100", }, @@ -250,7 +250,7 @@ func TestValidateLoadBalancerProfile(t *testing.T) { }, expectedErr: field.Error{ Type: field.ErrorTypeInvalid, - Field: "spec.LoadBalancerProfile.IdleTimeoutInMinutes", + Field: "spec.loadBalancerProfile.IdleTimeoutInMinutes", BadValue: ptr.To(600), Detail: "value should be in between 4 and 120", }, @@ -265,7 +265,7 @@ func TestValidateLoadBalancerProfile(t *testing.T) { }, expectedErr: field.Error{ Type: field.ErrorTypeForbidden, - Field: "spec.LoadBalancerProfile", + Field: "spec.loadBalancerProfile", BadValue: ptr.To(2), Detail: "load balancer profile must specify at most one of ManagedOutboundIPs, OutboundIPPrefixes and OutboundIPs", }, @@ -275,7 +275,7 @@ func TestValidateLoadBalancerProfile(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) - allErrs := validateLoadBalancerProfile(tt.profile, field.NewPath("spec").Child("LoadBalancerProfile")) + allErrs := validateLoadBalancerProfile(tt.profile, field.NewPath("spec").Child("loadBalancerProfile")) if tt.expectedErr != (field.Error{}) { g.Expect(allErrs).To(ContainElement(MatchError(tt.expectedErr.Error()))) } else { @@ -467,7 +467,7 @@ func TestValidateAutoScalerProfile(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) - allErrs := validateAutoScalerProfile(tt.profile, field.NewPath("spec").Child("AutoScalerProfile")) + allErrs := validateAutoScalerProfile(tt.profile, field.NewPath("spec").Child("autoScalerProfile")) if tt.expectErr { g.Expect(allErrs).NotTo(BeNil()) } else { @@ -3270,7 +3270,7 @@ func TestAzureManagedClusterSecurityProfileValidateCreate(t *testing.T) { }, }, }, - wantErr: "Spec.SecurityProfile.WorkloadIdentity: Invalid value: v1beta1.ManagedClusterSecurityProfileWorkloadIdentity{Enabled:true}: Spec.SecurityProfile.WorkloadIdentity cannot be enabled when Spec.OIDCIssuerProfile is disabled", + wantErr: "spec.securityProfile.workloadIdentity: Invalid value: v1beta1.ManagedClusterSecurityProfileWorkloadIdentity{Enabled:true}: Spec.SecurityProfile.WorkloadIdentity cannot be enabled when Spec.OIDCIssuerProfile is disabled", }, { name: "Cannot enable AzureKms without user assigned identity", @@ -3286,7 +3286,7 @@ func TestAzureManagedClusterSecurityProfileValidateCreate(t *testing.T) { }, }, }, - wantErr: "Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID: Invalid value: \"null\": Spec.SecurityProfile.AzureKeyVaultKms can be set only when Spec.Identity.Type is UserAssigned", + wantErr: "spec.securityProfile.azureKeyVaultKms.keyVaultResourceID: Invalid value: \"null\": Spec.SecurityProfile.AzureKeyVaultKms can be set only when Spec.Identity.Type is UserAssigned", }, { name: "When AzureKms.KeyVaultNetworkAccess is private AzureKeyVaultKms.KeyVaultResourceID cannot be empty", @@ -3308,7 +3308,7 @@ func TestAzureManagedClusterSecurityProfileValidateCreate(t *testing.T) { }, }, }, - wantErr: "Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID: Invalid value: \"null\": Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID cannot be empty when Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultNetworkAccess is Private", + wantErr: "spec.securityProfile.azureKeyVaultKms.keyVaultResourceID: Invalid value: \"null\": Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID cannot be empty when Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultNetworkAccess is Private", }, { name: "When AzureKms.KeyVaultNetworkAccess is public AzureKeyVaultKms.KeyVaultResourceID should be empty", @@ -3331,7 +3331,7 @@ func TestAzureManagedClusterSecurityProfileValidateCreate(t *testing.T) { }, }, }, - wantErr: "Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID: Invalid value: \"not empty\": Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID should be empty when Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultNetworkAccess is Public", + wantErr: "spec.securityProfile.azureKeyVaultKms.keyVaultResourceID: Invalid value: \"not empty\": Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID should be empty when Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultNetworkAccess is Public", }, { name: "Valid profile", @@ -3447,7 +3447,7 @@ func TestAzureClusterSecurityProfileValidateUpdate(t *testing.T) { }, }, }, - wantErr: "AzureManagedControlPlane.infrastructure.cluster.x-k8s.io \"\" is invalid: Spec.SecurityProfile.Defender: Invalid value: \"null\": cannot unset Spec.SecurityProfile.Defender, to disable defender please set Spec.SecurityProfile.Defender.SecurityMonitoring.Enabled to false", + wantErr: "AzureManagedControlPlane.infrastructure.cluster.x-k8s.io \"\" is invalid: spec.securityProfile.defender: Invalid value: \"null\": cannot unset Spec.SecurityProfile.Defender, to disable defender please set Spec.SecurityProfile.Defender.SecurityMonitoring.Enabled to false", }, { name: "AzureManagedControlPlane SecurityProfile.Defender is mutable and can be disabled", @@ -3530,7 +3530,7 @@ func TestAzureClusterSecurityProfileValidateUpdate(t *testing.T) { }, }, }, - wantErr: "Spec.SecurityProfile.WorkloadIdentity: Invalid value: v1beta1.ManagedClusterSecurityProfileWorkloadIdentity{Enabled:true}: Spec.SecurityProfile.WorkloadIdentity cannot be enabled when Spec.OIDCIssuerProfile is disabled", + wantErr: "spec.securityProfile.workloadIdentity: Invalid value: v1beta1.ManagedClusterSecurityProfileWorkloadIdentity{Enabled:true}: Spec.SecurityProfile.WorkloadIdentity cannot be enabled when Spec.OIDCIssuerProfile is disabled", }, { name: "AzureManagedControlPlane SecurityProfile.WorkloadIdentity cannot unset values", @@ -3559,7 +3559,7 @@ func TestAzureClusterSecurityProfileValidateUpdate(t *testing.T) { }, }, }, - wantErr: "AzureManagedControlPlane.infrastructure.cluster.x-k8s.io \"\" is invalid: Spec.SecurityProfile.WorkloadIdentity: Invalid value: \"null\": cannot unset Spec.SecurityProfile.WorkloadIdentity, to disable workloadIdentity please set Spec.SecurityProfile.WorkloadIdentity.Enabled to false", + wantErr: "AzureManagedControlPlane.infrastructure.cluster.x-k8s.io \"\" is invalid: spec.securityProfile.workloadIdentity: Invalid value: \"null\": cannot unset Spec.SecurityProfile.WorkloadIdentity, to disable workloadIdentity please set Spec.SecurityProfile.WorkloadIdentity.Enabled to false", }, { name: "AzureManagedControlPlane SecurityProfile.WorkloadIdentity can be disabled", @@ -3737,7 +3737,7 @@ func TestAzureClusterSecurityProfileValidateUpdate(t *testing.T) { }, }, }, - wantErr: "AzureManagedControlPlane.infrastructure.cluster.x-k8s.io \"\" is invalid: Spec.SecurityProfile.AzureKeyVaultKms: Invalid value: \"null\": cannot unset Spec.SecurityProfile.AzureKeyVaultKms profile to disable the profile please set Spec.SecurityProfile.AzureKeyVaultKms.Enabled to false", + wantErr: "AzureManagedControlPlane.infrastructure.cluster.x-k8s.io \"\" is invalid: spec.securityProfile.azureKeyVaultKms: Invalid value: \"null\": cannot unset Spec.SecurityProfile.AzureKeyVaultKms profile to disable the profile please set Spec.SecurityProfile.AzureKeyVaultKms.Enabled to false", }, { name: "AzureManagedControlPlane SecurityProfile.AzureKeyVaultKms cannot be enabled without UserAssigned Identity", @@ -3763,7 +3763,7 @@ func TestAzureClusterSecurityProfileValidateUpdate(t *testing.T) { }, }, }, - wantErr: "Spec.SecurityProfile.AzureKeyVaultKms.KeyVaultResourceID: Invalid value: \"0000-0000-0000-0000\": Spec.SecurityProfile.AzureKeyVaultKms can be set only when Spec.Identity.Type is UserAssigned", + wantErr: "spec.securityProfile.azureKeyVaultKms.keyVaultResourceID: Invalid value: \"0000-0000-0000-0000\": Spec.SecurityProfile.AzureKeyVaultKms can be set only when Spec.Identity.Type is UserAssigned", }, { name: "AzureManagedControlPlane SecurityProfile.ImageCleaner is mutable", @@ -3812,7 +3812,7 @@ func TestAzureClusterSecurityProfileValidateUpdate(t *testing.T) { }, }, }, - wantErr: "AzureManagedControlPlane.infrastructure.cluster.x-k8s.io \"\" is invalid: Spec.SecurityProfile.ImageCleaner: Invalid value: \"null\": cannot unset Spec.SecurityProfile.ImageCleaner, to disable imageCleaner please set Spec.SecurityProfile.ImageCleaner.Enabled to false", + wantErr: "AzureManagedControlPlane.infrastructure.cluster.x-k8s.io \"\" is invalid: spec.securityProfile.imageCleaner: Invalid value: \"null\": cannot unset Spec.SecurityProfile.ImageCleaner, to disable imageCleaner please set Spec.SecurityProfile.ImageCleaner.Enabled to false", }, { name: "AzureManagedControlPlane SecurityProfile.ImageCleaner is mutable", @@ -4248,7 +4248,7 @@ func TestValidateAMCPVirtualNetwork(t *testing.T) { err := mcpw.Default(context.Background(), tc.amcp) g.Expect(err).NotTo(HaveOccurred()) - errs := validateAMCPVirtualNetwork(tc.amcp.Spec.VirtualNetwork, field.NewPath("spec", "VirtualNetwork")) + errs := validateAMCPVirtualNetwork(tc.amcp.Spec.VirtualNetwork, field.NewPath("spec", "virtualNetwork")) if tc.wantErr != "" { g.Expect(errs).ToNot(BeEmpty()) g.Expect(errs[0].Detail).To(Equal(tc.wantErr)) diff --git a/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go b/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go index f9d820744b7..f2b25b36743 100644 --- a/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go +++ b/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go @@ -89,49 +89,49 @@ func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateUpdate(ctx context. return nil, apierrors.NewBadRequest("expected an AzureManagedControlPlaneTemplate") } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "SubscriptionID"), + field.NewPath("spec", "template", "spec", "subscriptionID"), old.Spec.Template.Spec.SubscriptionID, mcp.Spec.Template.Spec.SubscriptionID); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "Location"), + field.NewPath("spec", "template", "spec", "location"), old.Spec.Template.Spec.Location, mcp.Spec.Template.Spec.Location); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "DNSServiceIP"), + field.NewPath("spec", "template", "spec", "dnsServiceIP"), old.Spec.Template.Spec.DNSServiceIP, mcp.Spec.Template.Spec.DNSServiceIP); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "NetworkPlugin"), + field.NewPath("spec", "template", "spec", "networkPlugin"), old.Spec.Template.Spec.NetworkPlugin, mcp.Spec.Template.Spec.NetworkPlugin); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "NetworkPolicy"), + field.NewPath("spec", "template", "spec", "networkPolicy"), old.Spec.Template.Spec.NetworkPolicy, mcp.Spec.Template.Spec.NetworkPolicy); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "NetworkDataplane"), + field.NewPath("spec", "template", "spec", "networkDataplane"), old.Spec.Template.Spec.NetworkDataplane, mcp.Spec.Template.Spec.NetworkDataplane); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "LoadBalancerSKU"), + field.NewPath("spec", "template", "spec", "loadBalancerSKU"), old.Spec.Template.Spec.LoadBalancerSKU, mcp.Spec.Template.Spec.LoadBalancerSKU); err != nil { allErrs = append(allErrs, err) @@ -141,21 +141,21 @@ func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateUpdate(ctx context. if mcp.Spec.Template.Spec.AADProfile == nil { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Template", "Spec", "AADProfile"), + field.NewPath("spec", "template", "spec", "aadProfile"), mcp.Spec.Template.Spec.AADProfile, "field cannot be nil, cannot disable AADProfile")) } else { if !mcp.Spec.Template.Spec.AADProfile.Managed && old.Spec.Template.Spec.AADProfile.Managed { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Template", "Spec", "AADProfile.Managed"), + field.NewPath("spec", "template", "spec", "aadProfile", "managed"), mcp.Spec.Template.Spec.AADProfile.Managed, "cannot set AADProfile.Managed to false")) } if len(mcp.Spec.Template.Spec.AADProfile.AdminGroupObjectIDs) == 0 { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Template", "Spec", "AADProfile.AdminGroupObjectIDs"), + field.NewPath("spec", "template", "spec", "aadProfile", "adminGroupObjectIDs"), mcp.Spec.Template.Spec.AADProfile.AdminGroupObjectIDs, "length of AADProfile.AdminGroupObjectIDs cannot be zero")) } @@ -166,7 +166,7 @@ func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateUpdate(ctx context. // Updating outboundType after cluster creation (PREVIEW) // https://learn.microsoft.com/en-us/azure/aks/egress-outboundtype#updating-outboundtype-after-cluster-creation-preview if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "OutboundType"), + field.NewPath("spec", "template", "spec", "outboundType"), old.Spec.Template.Spec.OutboundType, mcp.Spec.Template.Spec.OutboundType); err != nil { allErrs = append(allErrs, err) @@ -200,11 +200,11 @@ func (mcp *AzureManagedControlPlaneTemplate) validateManagedControlPlaneTemplate allErrs = append(allErrs, validateVersion( mcp.Spec.Template.Spec.Version, - field.NewPath("spec").Child("template").Child("spec").Child("Version"))...) + field.NewPath("spec").Child("template").Child("spec").Child("version"))...) allErrs = append(allErrs, validateLoadBalancerProfile( mcp.Spec.Template.Spec.LoadBalancerProfile, - field.NewPath("spec").Child("template").Child("spec").Child("LoadBalancerProfile"))...) + field.NewPath("spec").Child("template").Child("spec").Child("loadBalancerProfile"))...) allErrs = append(allErrs, validateManagedClusterNetwork( cli, @@ -214,21 +214,21 @@ func (mcp *AzureManagedControlPlaneTemplate) validateManagedControlPlaneTemplate mcp.Spec.Template.Spec.VirtualNetwork.Subnet, field.NewPath("spec").Child("template").Child("spec"))...) - allErrs = append(allErrs, validateName(mcp.Name, field.NewPath("Name"))...) + allErrs = append(allErrs, validateName(mcp.Name, field.NewPath("name"))...) - allErrs = append(allErrs, validateAutoScalerProfile(mcp.Spec.Template.Spec.AutoScalerProfile, field.NewPath("spec").Child("template").Child("spec").Child("AutoScalerProfile"))...) + allErrs = append(allErrs, validateAutoScalerProfile(mcp.Spec.Template.Spec.AutoScalerProfile, field.NewPath("spec").Child("template").Child("spec").Child("autoScalerProfile"))...) - allErrs = append(allErrs, validateAKSExtensions(mcp.Spec.Template.Spec.Extensions, field.NewPath("spec").Child("Extensions"))...) + allErrs = append(allErrs, validateAKSExtensions(mcp.Spec.Template.Spec.Extensions, field.NewPath("spec").Child("extensions"))...) allErrs = append(allErrs, mcp.Spec.Template.Spec.AzureManagedControlPlaneClassSpec.validateSecurityProfile()...) - allErrs = append(allErrs, validateNetworkPolicy(mcp.Spec.Template.Spec.NetworkPolicy, mcp.Spec.Template.Spec.NetworkDataplane, field.NewPath("spec").Child("template").Child("spec").Child("NetworkPolicy"))...) + allErrs = append(allErrs, validateNetworkPolicy(mcp.Spec.Template.Spec.NetworkPolicy, mcp.Spec.Template.Spec.NetworkDataplane, field.NewPath("spec").Child("template").Child("spec").Child("networkPolicy"))...) - allErrs = append(allErrs, validateNetworkDataplane(mcp.Spec.Template.Spec.NetworkDataplane, mcp.Spec.Template.Spec.NetworkPolicy, mcp.Spec.Template.Spec.NetworkPluginMode, field.NewPath("spec").Child("template").Child("spec").Child("NetworkDataplane"))...) + allErrs = append(allErrs, validateNetworkDataplane(mcp.Spec.Template.Spec.NetworkDataplane, mcp.Spec.Template.Spec.NetworkPolicy, mcp.Spec.Template.Spec.NetworkPluginMode, field.NewPath("spec").Child("template").Child("spec").Child("networkDataplane"))...) - allErrs = append(allErrs, validateAPIServerAccessProfile(mcp.Spec.Template.Spec.APIServerAccessProfile, field.NewPath("spec").Child("template").Child("spec").Child("APIServerAccessProfile"))...) + allErrs = append(allErrs, validateAPIServerAccessProfile(mcp.Spec.Template.Spec.APIServerAccessProfile, field.NewPath("spec").Child("template").Child("spec").Child("apiServerAccessProfile"))...) - allErrs = append(allErrs, validateAMCPVirtualNetwork(mcp.Spec.Template.Spec.VirtualNetwork, field.NewPath("spec").Child("template").Child("spec").Child("VirtualNetwork"))...) + allErrs = append(allErrs, validateAMCPVirtualNetwork(mcp.Spec.Template.Spec.VirtualNetwork, field.NewPath("spec").Child("template").Child("spec").Child("virtualNetwork"))...) return allErrs.ToAggregate() } @@ -242,7 +242,7 @@ func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateDelete(ctx context. func (mcp *AzureManagedControlPlaneTemplate) validateK8sVersionUpdate(old *AzureManagedControlPlaneTemplate) field.ErrorList { var allErrs field.ErrorList if hv := versions.GetHigherK8sVersion(mcp.Spec.Template.Spec.Version, old.Spec.Template.Spec.Version); hv != mcp.Spec.Template.Spec.Version { - allErrs = append(allErrs, field.Invalid(field.NewPath("Spec", "Template", "Spec", "Version"), + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "template", "spec", "version"), mcp.Spec.Template.Spec.Version, "field version cannot be downgraded"), ) } @@ -256,7 +256,7 @@ func (mcp *AzureManagedControlPlaneTemplate) validateVirtualNetworkTemplateUpdat if old.Spec.Template.Spec.VirtualNetwork.CIDRBlock != mcp.Spec.Template.Spec.VirtualNetwork.CIDRBlock { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Template", "Spec", "VirtualNetwork.CIDRBlock"), + field.NewPath("spec", "template", "spec", "virtualNetwork", "cidrBlock"), mcp.Spec.Template.Spec.VirtualNetwork.CIDRBlock, "Virtual Network CIDRBlock is immutable")) } @@ -264,7 +264,7 @@ func (mcp *AzureManagedControlPlaneTemplate) validateVirtualNetworkTemplateUpdat if old.Spec.Template.Spec.VirtualNetwork.Subnet.Name != mcp.Spec.Template.Spec.VirtualNetwork.Subnet.Name { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Template", "Spec", "VirtualNetwork.Subnet.Name"), + field.NewPath("spec", "template", "spec", "virtualNetwork", "subnet", "name"), mcp.Spec.Template.Spec.VirtualNetwork.Subnet.Name, "Subnet Name is immutable")) } @@ -276,7 +276,7 @@ func (mcp *AzureManagedControlPlaneTemplate) validateVirtualNetworkTemplateUpdat if old.Spec.Template.Spec.VirtualNetwork.Subnet.CIDRBlock != mcp.Spec.Template.Spec.VirtualNetwork.Subnet.CIDRBlock { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Template", "Spec", "VirtualNetwork.Subnet.CIDRBlock"), + field.NewPath("spec", "template", "spec", "virtualNetwork", "subnet", "cidrBlock"), mcp.Spec.Template.Spec.VirtualNetwork.Subnet.CIDRBlock, "Subnet CIDRBlock is immutable")) } @@ -315,7 +315,7 @@ func (mcp *AzureManagedControlPlaneTemplate) validateAPIServerAccessProfileTempl if !reflect.DeepEqual(newAPIServerAccessProfileNormalized, oldAPIServerAccessProfileNormalized) { allErrs = append(allErrs, - field.Invalid(field.NewPath("Spec", "Template", "Spec", "APIServerAccessProfile"), + field.Invalid(field.NewPath("spec", "template", "spec", "apiServerAccessProfile"), mcp.Spec.Template.Spec.APIServerAccessProfile, "fields are immutable"), ) } diff --git a/api/v1beta1/azuremanagedmachinepool_webhook.go b/api/v1beta1/azuremanagedmachinepool_webhook.go index c5cee706f49..d5abde51657 100644 --- a/api/v1beta1/azuremanagedmachinepool_webhook.go +++ b/api/v1beta1/azuremanagedmachinepool_webhook.go @@ -103,44 +103,44 @@ func (mw *azureManagedMachinePoolWebhook) ValidateCreate(ctx context.Context, ob errs = append(errs, validateMaxPods( m.Spec.MaxPods, - field.NewPath("Spec", "MaxPods"))) + field.NewPath("spec", "maxPods"))) errs = append(errs, validateOSType( m.Spec.Mode, m.Spec.OSType, - field.NewPath("Spec", "OSType"))) + field.NewPath("spec", "osType"))) errs = append(errs, validateMPName( m.Name, m.Spec.Name, m.Spec.OSType, - field.NewPath("Spec", "Name"))) + field.NewPath("spec", "name"))) errs = append(errs, validateNodeLabels( m.Spec.NodeLabels, - field.NewPath("Spec", "NodeLabels"))) + field.NewPath("spec", "nodeLabels"))) errs = append(errs, validateNodePublicIPPrefixID( m.Spec.NodePublicIPPrefixID, - field.NewPath("Spec", "NodePublicIPPrefixID"))) + field.NewPath("spec", "nodePublicIPPrefixID"))) errs = append(errs, validateEnableNodePublicIP( m.Spec.EnableNodePublicIP, m.Spec.NodePublicIPPrefixID, - field.NewPath("Spec", "EnableNodePublicIP"))) + field.NewPath("spec", "enableNodePublicIP"))) errs = append(errs, validateKubeletConfig( m.Spec.KubeletConfig, - field.NewPath("Spec", "KubeletConfig"))) + field.NewPath("spec", "kubeletConfig"))) errs = append(errs, validateLinuxOSConfig( m.Spec.LinuxOSConfig, m.Spec.KubeletConfig, - field.NewPath("Spec", "LinuxOSConfig"))) + field.NewPath("spec", "linuxOSConfig"))) errs = append(errs, validateMPSubnetName( m.Spec.SubnetName, - field.NewPath("Spec", "SubnetName"))) + field.NewPath("spec", "subnetName"))) return nil, kerrors.NewAggregate(errs) } @@ -158,57 +158,57 @@ func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, ol var allErrs field.ErrorList if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Name"), + field.NewPath("spec", "name"), old.Spec.Name, m.Spec.Name); err != nil { allErrs = append(allErrs, err) } - if err := validateNodeLabels(m.Spec.NodeLabels, field.NewPath("Spec", "NodeLabels")); err != nil { + if err := validateNodeLabels(m.Spec.NodeLabels, field.NewPath("spec", "nodeLabels")); err != nil { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "NodeLabels"), + field.NewPath("spec", "nodeLabels"), m.Spec.NodeLabels, err.Error())) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "OSType"), + field.NewPath("spec", "osType"), old.Spec.OSType, m.Spec.OSType); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "SKU"), + field.NewPath("spec", "sku"), old.Spec.SKU, m.Spec.SKU); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "OSDiskSizeGB"), + field.NewPath("spec", "osDiskSizeGB"), old.Spec.OSDiskSizeGB, m.Spec.OSDiskSizeGB); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "SubnetName"), + field.NewPath("spec", "subnetName"), old.Spec.SubnetName, m.Spec.SubnetName); err != nil && old.Spec.SubnetName != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "EnableFIPS"), + field.NewPath("spec", "enableFIPS"), old.Spec.EnableFIPS, m.Spec.EnableFIPS); err != nil && old.Spec.EnableFIPS != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "EnableEncryptionAtHost"), + field.NewPath("spec", "enableEncryptionAtHost"), old.Spec.EnableEncryptionAtHost, m.Spec.EnableEncryptionAtHost); err != nil && old.Spec.EnableEncryptionAtHost != nil { allErrs = append(allErrs, err) @@ -217,7 +217,7 @@ func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, ol if !webhookutils.EnsureStringSlicesAreEquivalent(m.Spec.AvailabilityZones, old.Spec.AvailabilityZones) { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "AvailabilityZones"), + field.NewPath("spec", "availabilityZones"), m.Spec.AvailabilityZones, "field is immutable")) } @@ -226,67 +226,67 @@ func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, ol // validate for last system node pool if err := validateLastSystemNodePool(mw.Client, m.Labels, m.Namespace, m.Annotations); err != nil { allErrs = append(allErrs, field.Forbidden( - field.NewPath("Spec", "Mode"), + field.NewPath("spec", "mode"), "Cannot change node pool mode to User, you must have at least one System node pool in your cluster")) } } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "MaxPods"), + field.NewPath("spec", "maxPods"), old.Spec.MaxPods, m.Spec.MaxPods); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "OsDiskType"), + field.NewPath("spec", "osDiskType"), old.Spec.OsDiskType, m.Spec.OsDiskType); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "ScaleSetPriority"), + field.NewPath("spec", "scaleSetPriority"), old.Spec.ScaleSetPriority, m.Spec.ScaleSetPriority); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "EnableUltraSSD"), + field.NewPath("spec", "enableUltraSSD"), old.Spec.EnableUltraSSD, m.Spec.EnableUltraSSD); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "EnableNodePublicIP"), + field.NewPath("spec", "enableNodePublicIP"), old.Spec.EnableNodePublicIP, m.Spec.EnableNodePublicIP); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "NodePublicIPPrefixID"), + field.NewPath("spec", "nodePublicIPPrefixID"), old.Spec.NodePublicIPPrefixID, m.Spec.NodePublicIPPrefixID); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "KubeletConfig"), + field.NewPath("spec", "kubeletConfig"), old.Spec.KubeletConfig, m.Spec.KubeletConfig); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "KubeletDiskType"), + field.NewPath("spec", "kubeletDiskType"), old.Spec.KubeletDiskType, m.Spec.KubeletDiskType); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "LinuxOSConfig"), + field.NewPath("spec", "linuxOSConfig"), old.Spec.LinuxOSConfig, m.Spec.LinuxOSConfig); err != nil { allErrs = append(allErrs, err) diff --git a/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go b/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go index cc156d2ec42..9a85c5e1107 100644 --- a/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go +++ b/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go @@ -89,40 +89,40 @@ func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateCreate(ctx context.Co errs = append(errs, validateMaxPods( mp.Spec.Template.Spec.MaxPods, - field.NewPath("Spec", "Template", "Spec", "MaxPods"))) + field.NewPath("spec", "template", "spec", "maxPods"))) errs = append(errs, validateOSType( mp.Spec.Template.Spec.Mode, mp.Spec.Template.Spec.OSType, - field.NewPath("Spec", "Template", "Spec", "OSType"))) + field.NewPath("spec", "template", "spec", "osType"))) errs = append(errs, validateMPName( mp.Name, mp.Spec.Template.Spec.Name, mp.Spec.Template.Spec.OSType, - field.NewPath("Spec", "Template", "Spec", "Name"))) + field.NewPath("spec", "template", "spec", "name"))) errs = append(errs, validateNodeLabels( mp.Spec.Template.Spec.NodeLabels, - field.NewPath("Spec", "Template", "Spec", "NodeLabels"))) + field.NewPath("spec", "template", "spec", "nodeLabels"))) errs = append(errs, validateNodePublicIPPrefixID( mp.Spec.Template.Spec.NodePublicIPPrefixID, - field.NewPath("Spec", "Template", "Spec", "NodePublicIPPrefixID"))) + field.NewPath("spec", "template", "spec", "nodePublicIPPrefixID"))) errs = append(errs, validateEnableNodePublicIP( mp.Spec.Template.Spec.EnableNodePublicIP, mp.Spec.Template.Spec.NodePublicIPPrefixID, - field.NewPath("Spec", "Template", "Spec", "EnableNodePublicIP"))) + field.NewPath("spec", "template", "spec", "enableNodePublicIP"))) errs = append(errs, validateKubeletConfig( mp.Spec.Template.Spec.KubeletConfig, - field.NewPath("Spec", "Template", "Spec", "KubeletConfig"))) + field.NewPath("spec", "template", "spec", "kubeletConfig"))) errs = append(errs, validateLinuxOSConfig( mp.Spec.Template.Spec.LinuxOSConfig, mp.Spec.Template.Spec.KubeletConfig, - field.NewPath("Spec", "Template", "Spec", "LinuxOSConfig"))) + field.NewPath("spec", "template", "spec", "linuxOSConfig"))) return nil, kerrors.NewAggregate(errs) } @@ -140,50 +140,50 @@ func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateUpdate(ctx context.Co } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "Name"), + field.NewPath("spec", "template", "spec", "name"), old.Spec.Template.Spec.Name, mp.Spec.Template.Spec.Name); err != nil { allErrs = append(allErrs, err) } - if err := validateNodeLabels(mp.Spec.Template.Spec.NodeLabels, field.NewPath("Spec", "Template", "Spec", "NodeLabels")); err != nil { + if err := validateNodeLabels(mp.Spec.Template.Spec.NodeLabels, field.NewPath("spec", "template", "spec", "nodeLabels")); err != nil { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Template", "Spec", "NodeLabels"), + field.NewPath("spec", "template", "spec", "nodeLabels"), mp.Spec.Template.Spec.NodeLabels, err.Error())) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "OSType"), + field.NewPath("spec", "template", "spec", "osType"), old.Spec.Template.Spec.OSType, mp.Spec.Template.Spec.OSType); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "SKU"), + field.NewPath("spec", "template", "spec", "sku"), old.Spec.Template.Spec.SKU, mp.Spec.Template.Spec.SKU); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "OSDiskSizeGB"), + field.NewPath("spec", "template", "spec", "osDiskSizeGB"), old.Spec.Template.Spec.OSDiskSizeGB, mp.Spec.Template.Spec.OSDiskSizeGB); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "SubnetName"), + field.NewPath("spec", "template", "spec", "subnetName"), old.Spec.Template.Spec.SubnetName, mp.Spec.Template.Spec.SubnetName); err != nil && old.Spec.Template.Spec.SubnetName != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "EnableFIPS"), + field.NewPath("spec", "template", "spec", "enableFIPS"), old.Spec.Template.Spec.EnableFIPS, mp.Spec.Template.Spec.EnableFIPS); err != nil && old.Spec.Template.Spec.EnableFIPS != nil { allErrs = append(allErrs, err) @@ -192,7 +192,7 @@ func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateUpdate(ctx context.Co if !webhookutils.EnsureStringSlicesAreEquivalent(mp.Spec.Template.Spec.AvailabilityZones, old.Spec.Template.Spec.AvailabilityZones) { allErrs = append(allErrs, field.Invalid( - field.NewPath("Spec", "Template", "Spec", "AvailabilityZones"), + field.NewPath("spec", "template", "spec", "availabilityZones"), mp.Spec.Template.Spec.AvailabilityZones, "field is immutable")) } @@ -201,67 +201,67 @@ func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateUpdate(ctx context.Co // validate for last system node pool if err := validateLastSystemNodePool(mpw.Client, mp.Spec.Template.Spec.NodeLabels, mp.Namespace, mp.Annotations); err != nil { allErrs = append(allErrs, field.Forbidden( - field.NewPath("Spec", "Template", "Spec", "Mode"), + field.NewPath("spec", "template", "spec", "mode"), "Cannot change node pool mode to User, you must have at least one System node pool in your cluster")) } } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "MaxPods"), + field.NewPath("spec", "template", "spec", "maxPods"), old.Spec.Template.Spec.MaxPods, mp.Spec.Template.Spec.MaxPods); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "OsDiskType"), + field.NewPath("spec", "template", "spec", "osDiskType"), old.Spec.Template.Spec.OsDiskType, mp.Spec.Template.Spec.OsDiskType); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "ScaleSetPriority"), + field.NewPath("spec", "template", "spec", "scaleSetPriority"), old.Spec.Template.Spec.ScaleSetPriority, mp.Spec.Template.Spec.ScaleSetPriority); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "EnableUltraSSD"), + field.NewPath("spec", "template", "spec", "enableUltraSSD"), old.Spec.Template.Spec.EnableUltraSSD, mp.Spec.Template.Spec.EnableUltraSSD); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "EnableNodePublicIP"), + field.NewPath("spec", "template", "spec", "enableNodePublicIP"), old.Spec.Template.Spec.EnableNodePublicIP, mp.Spec.Template.Spec.EnableNodePublicIP); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "NodePublicIPPrefixID"), + field.NewPath("spec", "template", "spec", "nodePublicIPPrefixID"), old.Spec.Template.Spec.NodePublicIPPrefixID, mp.Spec.Template.Spec.NodePublicIPPrefixID); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "KubeletConfig"), + field.NewPath("spec", "template", "spec", "kubeletConfig"), old.Spec.Template.Spec.KubeletConfig, mp.Spec.Template.Spec.KubeletConfig); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "KubeletDiskType"), + field.NewPath("spec", "template", "spec", "kubeletDiskType"), old.Spec.Template.Spec.KubeletDiskType, mp.Spec.Template.Spec.KubeletDiskType); err != nil { allErrs = append(allErrs, err) } if err := webhookutils.ValidateImmutable( - field.NewPath("Spec", "Template", "Spec", "LinuxOSConfig"), + field.NewPath("spec", "template", "spec", "linuxOSConfig"), old.Spec.Template.Spec.LinuxOSConfig, mp.Spec.Template.Spec.LinuxOSConfig); err != nil { allErrs = append(allErrs, err) diff --git a/exp/api/v1beta1/azuremachinepool_webhook.go b/exp/api/v1beta1/azuremachinepool_webhook.go index 15c7af5ee3b..c64ee40c547 100644 --- a/exp/api/v1beta1/azuremachinepool_webhook.go +++ b/exp/api/v1beta1/azuremachinepool_webhook.go @@ -174,7 +174,7 @@ func (amp *AzureMachinePool) ValidateSSHKey() error { // ValidateUserAssignedIdentity validates the user-assigned identities list. func (amp *AzureMachinePool) ValidateUserAssignedIdentity() error { - fldPath := field.NewPath("UserAssignedIdentities") + fldPath := field.NewPath("userAssignedIdentities") if errs := infrav1.ValidateUserAssignedIdentity(amp.Spec.Identity, amp.Spec.UserAssignedIdentities, fldPath); len(errs) > 0 { return kerrors.NewAggregate(errs.ToAggregate().Errors()) } @@ -236,10 +236,10 @@ func (amp *AzureMachinePool) ValidateSystemAssignedIdentityRole() error { } if amp.Spec.Identity == infrav1.VMIdentitySystemAssigned { if amp.Spec.SystemAssignedIdentityRole.DefinitionID == "" { - allErrs = append(allErrs, field.Invalid(field.NewPath("systemAssignedIdentityRole", "DefinitionID"), amp.Spec.SystemAssignedIdentityRole.DefinitionID, "the roleDefinitionID field cannot be empty")) + allErrs = append(allErrs, field.Invalid(field.NewPath("systemAssignedIdentityRole", "definitionID"), amp.Spec.SystemAssignedIdentityRole.DefinitionID, "the roleDefinitionID field cannot be empty")) } if amp.Spec.SystemAssignedIdentityRole.Scope == "" { - allErrs = append(allErrs, field.Invalid(field.NewPath("systemAssignedIdentityRole", "Scope"), amp.Spec.SystemAssignedIdentityRole.Scope, "the scope field cannot be empty")) + allErrs = append(allErrs, field.Invalid(field.NewPath("systemAssignedIdentityRole", "scope"), amp.Spec.SystemAssignedIdentityRole.Scope, "the scope field cannot be empty")) } } if amp.Spec.Identity != infrav1.VMIdentitySystemAssigned && amp.Spec.SystemAssignedIdentityRole != nil { diff --git a/util/webhook/validator_test.go b/util/webhook/validator_test.go index 304887dbb68..b47d7bed9f8 100644 --- a/util/webhook/validator_test.go +++ b/util/webhook/validator_test.go @@ -25,7 +25,7 @@ import ( ) func TestValidateImmutableBoolPtr(t *testing.T) { - testPath := field.NewPath("Spec", "Foo") + testPath := field.NewPath("spec", "foo") tests := []struct { name string @@ -79,7 +79,7 @@ func TestValidateImmutableBoolPtr(t *testing.T) { } func TestValidateImmutableString(t *testing.T) { - testPath := field.NewPath("Spec", "Foo") + testPath := field.NewPath("spec", "foo") tests := []struct { name string @@ -133,7 +133,7 @@ func TestValidateImmutableString(t *testing.T) { } func TestValidateImmutableStringPtr(t *testing.T) { - testPath := field.NewPath("Spec", "Foo") + testPath := field.NewPath("spec", "foo") tests := []struct { name string @@ -187,7 +187,7 @@ func TestValidateImmutableStringPtr(t *testing.T) { } func TestValidateImmutableInt32(t *testing.T) { - testPath := field.NewPath("Spec", "Foo") + testPath := field.NewPath("spec", "foo") tests := []struct { name string @@ -300,7 +300,7 @@ func TestEnsureStringSlicesAreEquivalent(t *testing.T) { } func TestValidateZeroTransitionPtr(t *testing.T) { - testPath := field.NewPath("Spec", "Foo") + testPath := field.NewPath("spec", "foo") tests := []struct { name string @@ -353,7 +353,7 @@ func TestValidateZeroTransitionPtr(t *testing.T) { } func TestValidateZeroTransitionString(t *testing.T) { - testPath := field.NewPath("Spec", "Foo") + testPath := field.NewPath("spec", "foo") tests := []struct { name string @@ -406,7 +406,7 @@ func TestValidateZeroTransitionString(t *testing.T) { } func TestValidateZeroTransitionStringPtr(t *testing.T) { - testPath := field.NewPath("Spec", "Foo") + testPath := field.NewPath("spec", "foo") tests := []struct { name string @@ -459,7 +459,7 @@ func TestValidateZeroTransitionStringPtr(t *testing.T) { } func TestValidateZeroTransitionInt32(t *testing.T) { - testPath := field.NewPath("Spec", "Foo") + testPath := field.NewPath("spec", "foo") tests := []struct { name string