From 63c80b2769d4b4061dcad0d0b0c50f5951ab257e Mon Sep 17 00:00:00 2001 From: Deepak Muley Date: Thu, 29 Feb 2024 11:39:48 -0800 Subject: [PATCH] added cluster config variables --- api/v1alpha1/nutanix_clusterconfig_types.go | 42 +++++++-- api/v1alpha1/zz_generated.deepcopy.go | 94 ++++++++++++++++----- 2 files changed, 107 insertions(+), 29 deletions(-) diff --git a/api/v1alpha1/nutanix_clusterconfig_types.go b/api/v1alpha1/nutanix_clusterconfig_types.go index f00db48e3..f0b90ed5e 100644 --- a/api/v1alpha1/nutanix_clusterconfig_types.go +++ b/api/v1alpha1/nutanix_clusterconfig_types.go @@ -21,7 +21,7 @@ func (NutanixSpec) VariableSchema() clusterv1.VariableSchema { Properties: map[string]clusterv1.JSONSchemaProps{ "prismCentralEndpoint": NutanixPrismCentralEndpointSpec{}.VariableSchema().OpenAPIV3Schema, "controlPlaneEndpoint": NutanixControlPlaneEndpointSpec{}.VariableSchema().OpenAPIV3Schema, - // TODO "failureDomains": []NutanixFailureDomain{}.VariableSchema().OpenAPIV3Schema, + "failureDomains": NutanixFailureDomains{}.VariableSchema().OpenAPIV3Schema, }, }, } @@ -85,6 +85,20 @@ func (NutanixControlPlaneEndpointSpec) VariableSchema() clusterv1.VariableSchema } } +type NutanixFailureDomains []NutanixFailureDomain + +func (NutanixFailureDomains) VariableSchema() clusterv1.VariableSchema { + resourceSchema := NutanixFailureDomain{}.VariableSchema().OpenAPIV3Schema + + return clusterv1.VariableSchema{ + OpenAPIV3Schema: clusterv1.JSONSchemaProps{ + Description: "Nutanix failure domains", + Type: "array", + Items: &resourceSchema, + }, + } +} + type NutanixFailureDomain struct { // name defines the unique name of a failure domain. // Name is required and must be at most 64 characters in length. @@ -112,16 +126,32 @@ func (NutanixFailureDomain) VariableSchema() clusterv1.VariableSchema { OpenAPIV3Schema: clusterv1.JSONSchemaProps{ Description: "Nutanix Failure Domain", Type: "object", - Properties: map[string]clusterv1.JSONSchemaProps{ + Properties: map[string]clusterv1.JSONSchemaProps{ "name": { Description: "name of failure domain", Type: "string", }, - "cluster": { - Description: "", - Type: "integer", + "cluster": NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema, + "subnets": NutanixResourceIdentifiers{}.VariableSchema().OpenAPIV3Schema, + "controlPlane": { + Description: "indicates if a failure domain is suited for control plane nodes", + Type: "boolean", }, -}, + }, + }, + } +} + +type NutanixResourceIdentifiers []NutanixResourceIdentifier + +func (NutanixResourceIdentifiers) VariableSchema() clusterv1.VariableSchema { + resourceSchema := NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema + + return clusterv1.VariableSchema{ + OpenAPIV3Schema: clusterv1.JSONSchemaProps{ + Description: "Nutanix resource identifier", + Type: "array", + Items: &resourceSchema, }, } } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 9182c77fa..a5934c205 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -651,25 +651,9 @@ func (in *NodeConfigSpec) DeepCopy() *NodeConfigSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NutanixBootType) DeepCopyInto(out *NutanixBootType) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixBootType. -func (in *NutanixBootType) DeepCopy() *NutanixBootType { - if in == nil { - return nil - } - out := new(NutanixBootType) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NutanixCategoryIdentifier) DeepCopyInto(out *NutanixCategoryIdentifier) { *out = *in - in.NutanixResourceIdentifier.DeepCopyInto(&out.NutanixResourceIdentifier) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixCategoryIdentifier. @@ -700,7 +684,14 @@ func (in *NutanixControlPlaneEndpointSpec) DeepCopy() *NutanixControlPlaneEndpoi // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NutanixFailureDomain) DeepCopyInto(out *NutanixFailureDomain) { *out = *in - in.NutanixFailureDomain.DeepCopyInto(&out.NutanixFailureDomain) + in.Cluster.DeepCopyInto(&out.Cluster) + if in.Subnets != nil { + in, out := &in.Subnets, &out.Subnets + *out = make([]NutanixResourceIdentifier, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixFailureDomain. @@ -713,10 +704,40 @@ func (in *NutanixFailureDomain) DeepCopy() *NutanixFailureDomain { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in NutanixFailureDomains) DeepCopyInto(out *NutanixFailureDomains) { + { + in := &in + *out = make(NutanixFailureDomains, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixFailureDomains. +func (in NutanixFailureDomains) DeepCopy() NutanixFailureDomains { + if in == nil { + return nil + } + out := new(NutanixFailureDomains) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NutanixGPU) DeepCopyInto(out *NutanixGPU) { *out = *in - in.NutanixGPU.DeepCopyInto(&out.NutanixGPU) + if in.DeviceID != nil { + in, out := &in.DeviceID, &out.DeviceID + *out = new(int64) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixGPU. @@ -745,16 +766,13 @@ func (in *NutanixNodeSpec) DeepCopyInto(out *NutanixNodeSpec) { if in.AdditionalCategories != nil { in, out := &in.AdditionalCategories, &out.AdditionalCategories *out = make([]NutanixCategoryIdentifier, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + copy(*out, *in) } if in.Project != nil { in, out := &in.Project, &out.Project *out = new(NutanixResourceIdentifier) (*in).DeepCopyInto(*out) } - out.BootType = in.BootType out.SystemDiskSize = in.SystemDiskSize.DeepCopy() if in.GPUs != nil { in, out := &in.GPUs, &out.GPUs @@ -793,7 +811,16 @@ func (in *NutanixPrismCentralEndpointSpec) DeepCopy() *NutanixPrismCentralEndpoi // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NutanixResourceIdentifier) DeepCopyInto(out *NutanixResourceIdentifier) { *out = *in - in.NutanixResourceIdentifier.DeepCopyInto(&out.NutanixResourceIdentifier) + if in.UUID != nil { + in, out := &in.UUID, &out.UUID + *out = new(string) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixResourceIdentifier. @@ -806,6 +833,27 @@ func (in *NutanixResourceIdentifier) DeepCopy() *NutanixResourceIdentifier { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in NutanixResourceIdentifiers) DeepCopyInto(out *NutanixResourceIdentifiers) { + { + in := &in + *out = make(NutanixResourceIdentifiers, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NutanixResourceIdentifiers. +func (in NutanixResourceIdentifiers) DeepCopy() NutanixResourceIdentifiers { + if in == nil { + return nil + } + out := new(NutanixResourceIdentifiers) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NutanixSpec) DeepCopyInto(out *NutanixSpec) { *out = *in