From c00bb824f9e632147663241c55697143040eba41 Mon Sep 17 00:00:00 2001 From: Deepak Muley Date: Mon, 1 Apr 2024 13:39:52 -0700 Subject: [PATCH] incorporated review comments --- api/v1alpha1/nutanix_node_types.go | 2 +- api/v1alpha1/zz_generated.deepcopy.go | 2 +- .../machinedetails/inject_control_plane.go | 14 +++++------ .../mutation/machinedetails/inject_worker.go | 14 +++++------ .../mutation/machinedetails/variables_test.go | 2 +- .../mutation/prismcentralendpoint/inject.go | 23 ++++++++++--------- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/api/v1alpha1/nutanix_node_types.go b/api/v1alpha1/nutanix_node_types.go index baa99ad89..8038c49b3 100644 --- a/api/v1alpha1/nutanix_node_types.go +++ b/api/v1alpha1/nutanix_node_types.go @@ -133,7 +133,7 @@ func (NutanixMachineDetails) VariableSchema() clusterv1.VariableSchema { "image": NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema, "cluster": NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema, "subnet": NutanixResourceIdentifiers{}.VariableSchema().OpenAPIV3Schema, - "bootType": NutanixBootType("legacy").VariableSchema().OpenAPIV3Schema, + "bootType": NutanixBootType(NutanixBootTypeLegacy).VariableSchema().OpenAPIV3Schema, "systemDiskSize": { Description: "systemDiskSize is size (in Quantity format) of the system disk of the VM eg. 20Gi", Type: "string", diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 46d10152c..055355a3c 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -9,7 +9,7 @@ package v1alpha1 import ( "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/external/sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2" - v1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/pkg/handlers/nutanix/mutation/machinedetails/inject_control_plane.go b/pkg/handlers/nutanix/mutation/machinedetails/inject_control_plane.go index fbc5652bd..b7cb8f123 100644 --- a/pkg/handlers/nutanix/mutation/machinedetails/inject_control_plane.go +++ b/pkg/handlers/nutanix/mutation/machinedetails/inject_control_plane.go @@ -129,23 +129,23 @@ func (h *nutanixMachineDetailsControlPlanePatchHandler) Mutate( ) obj.Spec.Template.Spec.Subnets = make([]capxv1.NutanixResourceIdentifier, 0) - for _, subnetCRE := range nutanixMachineDetailsVar.Subnets { - if subnetCRE.Type == "" { + for _, subnetIdentifier := range nutanixMachineDetailsVar.Subnets { + if subnetIdentifier.Type == "" { continue } subnet := capxv1.NutanixResourceIdentifier{} - if subnetCRE.Type == v1alpha1.NutanixIdentifierName { + if subnetIdentifier.Type == v1alpha1.NutanixIdentifierName { subnet.Type = capxv1.NutanixIdentifierName - if subnetCRE.Name == nil || *subnetCRE.Name == "" { + if subnetIdentifier.Name == nil || *subnetIdentifier.Name == "" { continue } - subnet.Name = subnetCRE.Name + subnet.Name = subnetIdentifier.Name } else { subnet.Type = capxv1.NutanixIdentifierUUID - if subnetCRE.UUID == nil || *subnetCRE.UUID == "" { + if subnetIdentifier.UUID == nil || *subnetIdentifier.UUID == "" { continue } - subnet.UUID = subnetCRE.UUID + subnet.UUID = subnetIdentifier.UUID } obj.Spec.Template.Spec.Subnets = append(obj.Spec.Template.Spec.Subnets, subnet) } diff --git a/pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go b/pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go index 01e4ddd32..060324d27 100644 --- a/pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go +++ b/pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go @@ -122,23 +122,23 @@ func (h *nutanixMachineDetailsWorkerPatchHandler) Mutate( nutanixMachineDetailsVar.SystemDiskSize, ) obj.Spec.Template.Spec.Subnets = make([]capxv1.NutanixResourceIdentifier, 0) - for _, subnetCRE := range nutanixMachineDetailsVar.Subnets { - if subnetCRE.Type == "" { + for _, subnetIdentifier := range nutanixMachineDetailsVar.Subnets { + if subnetIdentifier.Type == "" { continue } subnet := capxv1.NutanixResourceIdentifier{} - if subnetCRE.Type == v1alpha1.NutanixIdentifierName { + if subnetIdentifier.Type == v1alpha1.NutanixIdentifierName { subnet.Type = capxv1.NutanixIdentifierName - if subnetCRE.Name == nil || *subnetCRE.Name == "" { + if subnetIdentifier.Name == nil || *subnetIdentifier.Name == "" { continue } - subnet.Name = subnetCRE.Name + subnet.Name = subnetIdentifier.Name } else { subnet.Type = capxv1.NutanixIdentifierUUID - if subnetCRE.UUID == nil || *subnetCRE.UUID == "" { + if subnetIdentifier.UUID == nil || *subnetIdentifier.UUID == "" { continue } - subnet.UUID = subnetCRE.UUID + subnet.UUID = subnetIdentifier.UUID } obj.Spec.Template.Spec.Subnets = append(obj.Spec.Template.Spec.Subnets, subnet) } diff --git a/pkg/handlers/nutanix/mutation/machinedetails/variables_test.go b/pkg/handlers/nutanix/mutation/machinedetails/variables_test.go index 8115270ff..d4764f826 100644 --- a/pkg/handlers/nutanix/mutation/machinedetails/variables_test.go +++ b/pkg/handlers/nutanix/mutation/machinedetails/variables_test.go @@ -30,7 +30,7 @@ func TestVariableValidation(t *testing.T) { ControlPlane: &v1alpha1.NodeConfigSpec{ Nutanix: &v1alpha1.NutanixNodeSpec{ MachineDetails: &v1alpha1.NutanixMachineDetails{ - BootType: "legacy", + BootType: v1alpha1.NutanixBootTypeLegacy, VCPUSockets: 2, VCPUsPerSocket: 1, Image: v1alpha1.NutanixResourceIdentifier{ diff --git a/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject.go b/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject.go index b62d11464..68076ceed 100644 --- a/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject.go +++ b/pkg/handlers/nutanix/mutation/prismcentralendpoint/inject.go @@ -94,17 +94,18 @@ func (h *nutanixPrismCentralEndpoint) Mutate( "patchedObjectName", client.ObjectKeyFromObject(obj), ).Info("setting prismCentralEndpoint in NutanixCluster spec") - obj.Spec.Template.Spec.PrismCentral = &credentials.NutanixPrismEndpoint{} - obj.Spec.Template.Spec.PrismCentral.Address = prismCentralEndpointVar.Host - obj.Spec.Template.Spec.PrismCentral.Port = prismCentralEndpointVar.Port - obj.Spec.Template.Spec.PrismCentral.Insecure = prismCentralEndpointVar.Insecure - obj.Spec.Template.Spec.PrismCentral.AdditionalTrustBundle = &credentials.NutanixTrustBundleReference{ - Kind: credentials.NutanixTrustBundleKindConfigMap, - Name: prismCentralEndpointVar.AdditionalTrustBundle, - } - obj.Spec.Template.Spec.PrismCentral.CredentialRef = &credentials.NutanixCredentialReference{ - Kind: credentials.SecretKind, - Name: prismCentralEndpointVar.CredentialSecret, + obj.Spec.Template.Spec.PrismCentral = &credentials.NutanixPrismEndpoint{ + Address: prismCentralEndpointVar.Host, + Port: prismCentralEndpointVar.Port, + Insecure: prismCentralEndpointVar.Insecure, + AdditionalTrustBundle: &credentials.NutanixTrustBundleReference{ + Kind: credentials.NutanixTrustBundleKindConfigMap, + Name: prismCentralEndpointVar.AdditionalTrustBundle, + }, + CredentialRef: &credentials.NutanixCredentialReference{ + Kind: credentials.SecretKind, + Name: prismCentralEndpointVar.CredentialSecret, + }, } return nil