Skip to content

Commit

Permalink
resolved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshkeswani committed Jun 20, 2024
1 parent e333559 commit 2f67a1d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion api/v1beta1/azuremachine_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/azuremachinetemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (r *AzureMachineTemplate) ValidateUpdate(ctx context.Context, oldRaw runtim

if err := r.Default(ctx, old); err != nil {
allErrs = append(allErrs,
field.Invalid(field.NewPath("azureMachineTemplate"), r, fmt.Sprintf("Unable to apply defaults: %v", err)),
field.Invalid(field.NewPath("AzureMachineTemplate"), r, fmt.Sprintf("Unable to apply defaults: %v", err)),
)
}

Expand Down
14 changes: 7 additions & 7 deletions api/v1beta1/azuremanagedcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,23 +709,23 @@ 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"))
}

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"))
}

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"))
}
Expand All @@ -737,15 +737,15 @@ 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"))
}

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"))
}
Expand Down Expand Up @@ -779,14 +779,14 @@ func (m *AzureManagedControlPlane) validateAADProfileUpdateAndLocalAccounts(old
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"))
}
Expand Down
10 changes: 5 additions & 5 deletions api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateUpdate(ctx context.
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"))
}
Expand Down Expand Up @@ -256,15 +256,15 @@ 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"))
}

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"),

Check warning on line 267 in api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go

View check run for this annotation

Codecov / codecov/patch

api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go#L267

Added line #L267 was not covered by tests
mcp.Spec.Template.Spec.VirtualNetwork.Subnet.Name,
"Subnet Name is immutable"))
}
Expand All @@ -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"),

Check warning on line 279 in api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go

View check run for this annotation

Codecov / codecov/patch

api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go#L279

Added line #L279 was not covered by tests
mcp.Spec.Template.Spec.VirtualNetwork.Subnet.CIDRBlock,
"Subnet CIDRBlock is immutable"))
}
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 @@ -89,7 +89,7 @@ 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")))

Check warning on line 92 in api/v1beta1/azuremanagedmachinepooltemplate_webhook.go

View check run for this annotation

Codecov / codecov/patch

api/v1beta1/azuremanagedmachinepooltemplate_webhook.go#L92

Added line #L92 was not covered by tests

errs = append(errs, validateOSType(
mp.Spec.Template.Spec.Mode,
Expand Down

0 comments on commit 2f67a1d

Please sign in to comment.