From f0ffda0bbeb0479c0f5369a06ee0b185134988a8 Mon Sep 17 00:00:00 2001 From: Johannes Frey Date: Thu, 31 Aug 2023 11:17:47 +0200 Subject: [PATCH] Add MachinePool Builders --- .../kubeadmconfig_controller_test.go | 2 +- internal/test/builder/builders.go | 434 +++++++++++++++++- internal/test/builder/infrastructure.go | 12 + .../test/builder/zz_generated.deepcopy.go | 223 ++++++++- 4 files changed, 647 insertions(+), 24 deletions(-) diff --git a/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller_test.go b/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller_test.go index ef334b2eda94..8c193f169cb9 100644 --- a/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller_test.go +++ b/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller_test.go @@ -2249,7 +2249,7 @@ func newMachinePool(cluster *clusterv1.Cluster, name string) *expv1.MachinePool m := builder.MachinePool(cluster.Namespace, name). WithClusterName(cluster.Name). WithLabels(map[string]string{clusterv1.ClusterNameLabel: cluster.Name}). - WithBootstrapTemplate(bootstrapbuilder.KubeadmConfig(cluster.Namespace, "conf1").Unstructured()). + WithBootstrap(bootstrapbuilder.KubeadmConfig(cluster.Namespace, "conf1").Unstructured()). WithVersion("1.19.1"). Build() return m diff --git a/internal/test/builder/builders.go b/internal/test/builder/builders.go index af37d75d4f56..92037392a096 100644 --- a/internal/test/builder/builders.go +++ b/internal/test/builder/builders.go @@ -160,6 +160,12 @@ func (c *ClusterTopologyBuilder) WithMachineDeployment(mdc clusterv1.MachineDepl return c } +// WithMachinePool passes the full MachinePoolTopology and adds it to an existing list in the ClusterTopologyBuilder. +func (c *ClusterTopologyBuilder) WithMachinePool(mpc clusterv1.MachinePoolTopology) *ClusterTopologyBuilder { + c.workers.MachinePools = append(c.workers.MachinePools, mpc) + return c +} + // WithVariables adds the passed variables to the ClusterTopologyBuilder. func (c *ClusterTopologyBuilder) WithVariables(vars ...clusterv1.ClusterVariable) *ClusterTopologyBuilder { c.variables = vars @@ -238,6 +244,64 @@ func (m *MachineDeploymentTopologyBuilder) Build() clusterv1.MachineDeploymentTo return md } +// MachinePoolTopologyBuilder holds the values needed to create a testable MachinePoolTopology. +type MachinePoolTopologyBuilder struct { + class string + name string + replicas *int32 + failureDomains []string + variables []clusterv1.ClusterVariable +} + +// MachinePoolTopology returns a builder used to create a testable MachinePoolTopology. +func MachinePoolTopology(name string) *MachinePoolTopologyBuilder { + return &MachinePoolTopologyBuilder{ + name: name, + } +} + +// WithClass adds a class string used as the MachinePoolTopology class. +func (m *MachinePoolTopologyBuilder) WithClass(class string) *MachinePoolTopologyBuilder { + m.class = class + return m +} + +// WithReplicas adds a replicas value used as the MachinePoolTopology replicas value. +func (m *MachinePoolTopologyBuilder) WithReplicas(replicas int32) *MachinePoolTopologyBuilder { + m.replicas = &replicas + return m +} + +// WithFailureDomains adds a failureDomains value used as the MachinePoolTopology failureDomains value. +func (m *MachinePoolTopologyBuilder) WithFailureDomains(failureDomains ...string) *MachinePoolTopologyBuilder { + m.failureDomains = failureDomains + return m +} + +// WithVariables adds variables used as the MachinePoolTopology variables value. +func (m *MachinePoolTopologyBuilder) WithVariables(variables ...clusterv1.ClusterVariable) *MachinePoolTopologyBuilder { + m.variables = variables + return m +} + +// Build returns a testable MachinePoolTopology with any values passed to the builder. +func (m *MachinePoolTopologyBuilder) Build() clusterv1.MachinePoolTopology { + mp := clusterv1.MachinePoolTopology{ + Class: m.class, + Name: m.name, + Replicas: m.replicas, + FailureDomains: m.failureDomains, + } + + if len(m.variables) > 0 { + mp.Variables = &clusterv1.MachinePoolVariables{ + Overrides: m.variables, + } + } + + return mp +} + // ClusterClassBuilder holds the variables and objects required to build a clusterv1.ClusterClass. type ClusterClassBuilder struct { namespace string @@ -251,6 +315,7 @@ type ClusterClassBuilder struct { controlPlaneNodeVolumeDetachTimeout *metav1.Duration controlPlaneNodeDeletionTimeout *metav1.Duration machineDeploymentClasses []clusterv1.MachineDeploymentClass + machinePoolClasses []clusterv1.MachinePoolClass variables []clusterv1.ClusterClassVariable statusVariables []clusterv1.ClusterClassStatusVariable patches []clusterv1.ClusterClassPatch @@ -342,6 +407,15 @@ func (c *ClusterClassBuilder) WithWorkerMachineDeploymentClasses(mdcs ...cluster return c } +// WithWorkerMachinePoolClasses adds the variables and objects needed to create MachinePoolTemplates for a ClusterClassBuilder. +func (c *ClusterClassBuilder) WithWorkerMachinePoolClasses(mpcs ...clusterv1.MachinePoolClass) *ClusterClassBuilder { + if c.machinePoolClasses == nil { + c.machinePoolClasses = make([]clusterv1.MachinePoolClass, 0) + } + c.machinePoolClasses = append(c.machinePoolClasses, mpcs...) + return c +} + // Build takes the objects and variables in the ClusterClass builder and uses them to create a ClusterClass object. func (c *ClusterClassBuilder) Build() *clusterv1.ClusterClass { obj := &clusterv1.ClusterClass{ @@ -393,6 +467,7 @@ func (c *ClusterClassBuilder) Build() *clusterv1.ClusterClass { } obj.Spec.Workers.MachineDeployments = c.machineDeploymentClasses + obj.Spec.Workers.MachinePools = c.machinePoolClasses return obj } @@ -526,6 +601,116 @@ func (m *MachineDeploymentClassBuilder) Build() *clusterv1.MachineDeploymentClas return obj } +// MachinePoolClassBuilder holds the variables and objects required to build a clusterv1.MachinePoolClass. +type MachinePoolClassBuilder struct { + class string + infrastructureMachinePoolTemplate *unstructured.Unstructured + bootstrapTemplate *unstructured.Unstructured + labels map[string]string + annotations map[string]string + failureDomains []string + nodeDrainTimeout *metav1.Duration + nodeVolumeDetachTimeout *metav1.Duration + nodeDeletionTimeout *metav1.Duration + minReadySeconds *int32 +} + +// MachinePoolClass returns a MachinePoolClassBuilder with the given name and namespace. +func MachinePoolClass(class string) *MachinePoolClassBuilder { + return &MachinePoolClassBuilder{ + class: class, + } +} + +// WithInfrastructureTemplate registers the passed Unstructured object as the InfrastructureMachinePoolTemplate for the MachinePoolClassBuilder. +func (m *MachinePoolClassBuilder) WithInfrastructureTemplate(t *unstructured.Unstructured) *MachinePoolClassBuilder { + m.infrastructureMachinePoolTemplate = t + return m +} + +// WithBootstrapTemplate registers the passed Unstructured object as the BootstrapTemplate for the MachinePoolClassBuilder. +func (m *MachinePoolClassBuilder) WithBootstrapTemplate(t *unstructured.Unstructured) *MachinePoolClassBuilder { + m.bootstrapTemplate = t + return m +} + +// WithLabels sets the labels for the MachinePoolClassBuilder. +func (m *MachinePoolClassBuilder) WithLabels(labels map[string]string) *MachinePoolClassBuilder { + m.labels = labels + return m +} + +// WithAnnotations sets the annotations for the MachinePoolClassBuilder. +func (m *MachinePoolClassBuilder) WithAnnotations(annotations map[string]string) *MachinePoolClassBuilder { + m.annotations = annotations + return m +} + +// WithFailureDomains sets the FailureDomains for the MachinePoolClassBuilder. +func (m *MachinePoolClassBuilder) WithFailureDomains(failureDomains ...string) *MachinePoolClassBuilder { + m.failureDomains = failureDomains + return m +} + +// WithNodeDrainTimeout sets the NodeDrainTimeout for the MachinePoolClassBuilder. +func (m *MachinePoolClassBuilder) WithNodeDrainTimeout(t *metav1.Duration) *MachinePoolClassBuilder { + m.nodeDrainTimeout = t + return m +} + +// WithNodeVolumeDetachTimeout sets the NodeVolumeDetachTimeout for the MachinePoolClassBuilder. +func (m *MachinePoolClassBuilder) WithNodeVolumeDetachTimeout(t *metav1.Duration) *MachinePoolClassBuilder { + m.nodeVolumeDetachTimeout = t + return m +} + +// WithNodeDeletionTimeout sets the NodeDeletionTimeout for the MachinePoolClassBuilder. +func (m *MachinePoolClassBuilder) WithNodeDeletionTimeout(t *metav1.Duration) *MachinePoolClassBuilder { + m.nodeDeletionTimeout = t + return m +} + +// WithMinReadySeconds sets the MinReadySeconds for the MachinePoolClassBuilder. +func (m *MachinePoolClassBuilder) WithMinReadySeconds(t *int32) *MachinePoolClassBuilder { + m.minReadySeconds = t + return m +} + +// Build creates a full MachinePoolClass object with the variables passed to the MachinePoolClassBuilder. +func (m *MachinePoolClassBuilder) Build() *clusterv1.MachinePoolClass { + obj := &clusterv1.MachinePoolClass{ + Class: m.class, + Template: clusterv1.MachinePoolClassTemplate{ + Metadata: clusterv1.ObjectMeta{ + Labels: m.labels, + Annotations: m.annotations, + }, + }, + } + if m.bootstrapTemplate != nil { + obj.Template.Bootstrap.Ref = objToRef(m.bootstrapTemplate) + } + if m.infrastructureMachinePoolTemplate != nil { + obj.Template.Infrastructure.Ref = objToRef(m.infrastructureMachinePoolTemplate) + } + if m.failureDomains != nil { + obj.FailureDomains = m.failureDomains + } + if m.nodeDrainTimeout != nil { + obj.NodeDrainTimeout = m.nodeDrainTimeout + } + if m.nodeVolumeDetachTimeout != nil { + obj.NodeVolumeDetachTimeout = m.nodeVolumeDetachTimeout + } + if m.nodeDeletionTimeout != nil { + obj.NodeDeletionTimeout = m.nodeDeletionTimeout + } + if m.minReadySeconds != nil { + obj.MinReadySeconds = m.minReadySeconds + } + return obj +} + // InfrastructureMachineTemplateBuilder holds the variables and objects needed to build an InfrastructureMachineTemplate. type InfrastructureMachineTemplateBuilder struct { obj *unstructured.Unstructured @@ -602,6 +787,158 @@ func (i *TestInfrastructureMachineTemplateBuilder) Build() *unstructured.Unstruc return i.obj } +// InfrastructureMachinePoolTemplateBuilder holds the variables and objects needed to build an InfrastructureMachinePoolTemplate. +type InfrastructureMachinePoolTemplateBuilder struct { + obj *unstructured.Unstructured +} + +// InfrastructureMachinePoolTemplate creates an InfrastructureMachinePoolTemplateBuilder with the given name and namespace. +func InfrastructureMachinePoolTemplate(namespace, name string) *InfrastructureMachinePoolTemplateBuilder { + obj := &unstructured.Unstructured{} + obj.SetName(name) + obj.SetNamespace(namespace) + obj.SetAPIVersion(InfrastructureGroupVersion.String()) + obj.SetKind(GenericInfrastructureMachinePoolTemplateKind) + // Set the mandatory spec fields for the object. + setSpecFields(obj, map[string]interface{}{"spec.template.spec": map[string]interface{}{}}) + return &InfrastructureMachinePoolTemplateBuilder{ + obj, + } +} + +// WithSpecFields sets a map of spec fields on the unstructured object. The keys in the map represent the path and the value corresponds +// to the value of the spec field. +// +// Note: all the paths should start with "spec." +// +// Example map: map[string]interface{}{ +// "spec.version": "v1.2.3", +// }. +func (i *InfrastructureMachinePoolTemplateBuilder) WithSpecFields(fields map[string]interface{}) *InfrastructureMachinePoolTemplateBuilder { + setSpecFields(i.obj, fields) + return i +} + +// Build takes the objects and variables in the InfrastructureMachineTemplateBuilder and generates an unstructured object. +func (i *InfrastructureMachinePoolTemplateBuilder) Build() *unstructured.Unstructured { + return i.obj +} + +// TestInfrastructureMachinePoolTemplateBuilder holds the variables and objects needed to build an TestInfrastructureMachinePoolTemplate. +type TestInfrastructureMachinePoolTemplateBuilder struct { + obj *unstructured.Unstructured +} + +// TestInfrastructureMachinePoolTemplate creates an TestInfrastructureMachinePoolTemplateBuilder with the given name and namespace. +func TestInfrastructureMachinePoolTemplate(namespace, name string) *TestInfrastructureMachinePoolTemplateBuilder { + obj := &unstructured.Unstructured{} + obj.SetName(name) + obj.SetNamespace(namespace) + obj.SetAPIVersion(InfrastructureGroupVersion.String()) + obj.SetKind(TestInfrastructureMachinePoolTemplateKind) + // Set the mandatory spec fields for the object. + if err := unstructured.SetNestedField(obj.Object, map[string]interface{}{}, "spec", "template", "spec"); err != nil { + panic(err) + } + return &TestInfrastructureMachinePoolTemplateBuilder{ + obj, + } +} + +// WithSpecFields sets a map of spec fields on the unstructured object. The keys in the map represent the path and the value corresponds +// to the value of the spec field. +// +// Note: all the paths should start with "spec."; the path should correspond to a field defined in the CRD. +// +// Example map: map[string]interface{}{ +// "spec.version": "v1.2.3", +// }. +func (i *TestInfrastructureMachinePoolTemplateBuilder) WithSpecFields(fields map[string]interface{}) *TestInfrastructureMachinePoolTemplateBuilder { + setSpecFields(i.obj, fields) + return i +} + +// Build takes the objects and variables in the TestInfrastructureMachineTemplateBuilder and generates an unstructured object. +func (i *TestInfrastructureMachinePoolTemplateBuilder) Build() *unstructured.Unstructured { + return i.obj +} + +// InfrastructureMachinePoolBuilder holds the variables and objects needed to build an InfrastructureMachinePool. +type InfrastructureMachinePoolBuilder struct { + obj *unstructured.Unstructured +} + +// InfrastructureMachinePool creates an InfrastructureMachinePoolBuilder with the given name and namespace. +func InfrastructureMachinePool(namespace, name string) *InfrastructureMachinePoolBuilder { + obj := &unstructured.Unstructured{} + obj.SetName(name) + obj.SetNamespace(namespace) + obj.SetAPIVersion(InfrastructureGroupVersion.String()) + obj.SetKind(GenericInfrastructureMachinePoolKind) + // Set the mandatory spec fields for the object. + setSpecFields(obj, map[string]interface{}{"spec": map[string]interface{}{}}) + return &InfrastructureMachinePoolBuilder{ + obj, + } +} + +// WithSpecFields sets a map of spec fields on the unstructured object. The keys in the map represent the path and the value corresponds +// to the value of the spec field. +// +// Note: all the paths should start with "spec." +// +// Example map: map[string]interface{}{ +// "spec.version": "v1.2.3", +// }. +func (i *InfrastructureMachinePoolBuilder) WithSpecFields(fields map[string]interface{}) *InfrastructureMachinePoolBuilder { + setSpecFields(i.obj, fields) + return i +} + +// Build takes the objects and variables in the InfrastructureMachinePoolBuilder and generates an unstructured object. +func (i *InfrastructureMachinePoolBuilder) Build() *unstructured.Unstructured { + return i.obj +} + +// TestInfrastructureMachinePoolBuilder holds the variables and objects needed to build an TestInfrastructureMachinePool. +type TestInfrastructureMachinePoolBuilder struct { + obj *unstructured.Unstructured +} + +// TestInfrastructureMachinePool creates an TestInfrastructureMachinePoolBuilder with the given name and namespace. +func TestInfrastructureMachinePool(namespace, name string) *TestInfrastructureMachinePoolBuilder { + obj := &unstructured.Unstructured{} + obj.SetName(name) + obj.SetNamespace(namespace) + obj.SetAPIVersion(InfrastructureGroupVersion.String()) + obj.SetKind(TestInfrastructureMachinePoolKind) + // Set the mandatory spec fields for the object. + if err := unstructured.SetNestedField(obj.Object, map[string]interface{}{}, "spec"); err != nil { + panic(err) + } + return &TestInfrastructureMachinePoolBuilder{ + obj, + } +} + +// WithSpecFields sets a map of spec fields on the unstructured object. The keys in the map represent the path and the value corresponds +// to the value of the spec field. +// +// Note: all the paths should start with "spec."; the path should correspond to a field defined in the CRD. +// +// Example map: map[string]interface{}{ +// "spec.version": "v1.2.3", +// }. +func (i *TestInfrastructureMachinePoolBuilder) WithSpecFields(fields map[string]interface{}) *TestInfrastructureMachinePoolBuilder { + setSpecFields(i.obj, fields) + return i +} + +// Build takes the objects and variables in the TestInfrastructureMachinePoolBuilder and generates an unstructured object. +func (i *TestInfrastructureMachinePoolBuilder) Build() *unstructured.Unstructured { + return i.obj +} + // BootstrapTemplateBuilder holds the variables needed to build a generic BootstrapTemplate. type BootstrapTemplateBuilder struct { obj *unstructured.Unstructured @@ -661,6 +998,65 @@ func (b *TestBootstrapTemplateBuilder) Build() *unstructured.Unstructured { return b.obj } +// BootstrapConfigBuilder holds the variables needed to build a generic BootstrapConfig. +type BootstrapConfigBuilder struct { + obj *unstructured.Unstructured +} + +// BootstrapConfig creates a BootstrapConfigBuilder with the given name and namespace. +func BootstrapConfig(namespace, name string) *BootstrapConfigBuilder { + obj := &unstructured.Unstructured{} + obj.SetAPIVersion(BootstrapGroupVersion.String()) + obj.SetKind(GenericBootstrapConfigKind) + obj.SetNamespace(namespace) + obj.SetName(name) + setSpecFields(obj, map[string]interface{}{"spec": map[string]interface{}{}}) + + return &BootstrapConfigBuilder{obj: obj} +} + +// WithSpecFields will add fields of any type to the object spec. It takes an argument, fields, which is of the form path: object. +func (b *BootstrapConfigBuilder) WithSpecFields(fields map[string]interface{}) *BootstrapConfigBuilder { + setSpecFields(b.obj, fields) + return b +} + +// Build creates a new Unstructured object with the information passed to the BootstrapConfigBuilder. +func (b *BootstrapConfigBuilder) Build() *unstructured.Unstructured { + return b.obj +} + +// TestBootstrapConfigBuilder holds the variables needed to build a generic TestBootstrapConfig. +type TestBootstrapConfigBuilder struct { + obj *unstructured.Unstructured +} + +// TestBootstrapConfig creates a TestBootstrapConfigBuilder with the given name and namespace. +func TestBootstrapConfig(namespace, name string) *TestBootstrapConfigBuilder { + obj := &unstructured.Unstructured{} + obj.SetAPIVersion(BootstrapGroupVersion.String()) + obj.SetKind(TestBootstrapConfigKind) + obj.SetNamespace(namespace) + obj.SetName(name) + setSpecFields(obj, map[string]interface{}{"spec": map[string]interface{}{}}) + + return &TestBootstrapConfigBuilder{ + obj: obj, + } +} + +// WithSpecFields will add fields of any type to the object spec. It takes an argument, fields, which is of the form path: object. +// NOTE: The path should correspond to a field defined in the CRD. +func (b *TestBootstrapConfigBuilder) WithSpecFields(fields map[string]interface{}) *TestBootstrapConfigBuilder { + setSpecFields(b.obj, fields) + return b +} + +// Build creates a new Unstructured object with the information passed to the BootstrapConfigBuilder. +func (b *TestBootstrapConfigBuilder) Build() *unstructured.Unstructured { + return b.obj +} + // InfrastructureClusterTemplateBuilder holds the variables needed to build a generic InfrastructureClusterTemplate. type InfrastructureClusterTemplateBuilder struct { obj *unstructured.Unstructured @@ -1044,15 +1440,15 @@ func (c *TestControlPlaneBuilder) Build() *unstructured.Unstructured { // MachinePoolBuilder holds the variables and objects needed to build a generic MachinePool. type MachinePoolBuilder struct { - namespace string - name string - bootstrapTemplate *unstructured.Unstructured - infrastructureTemplate *unstructured.Unstructured - version *string - clusterName string - replicas *int32 - labels map[string]string - status *expv1.MachinePoolStatus + namespace string + name string + bootstrap *unstructured.Unstructured + infrastructure *unstructured.Unstructured + version *string + clusterName string + replicas *int32 + labels map[string]string + status *expv1.MachinePoolStatus } // MachinePool creates a MachinePoolBuilder with the given name and namespace. @@ -1063,15 +1459,15 @@ func MachinePool(namespace, name string) *MachinePoolBuilder { } } -// WithBootstrapTemplate adds the passed Unstructured object to the MachinePoolBuilder as a bootstrapTemplate. -func (m *MachinePoolBuilder) WithBootstrapTemplate(ref *unstructured.Unstructured) *MachinePoolBuilder { - m.bootstrapTemplate = ref +// WithBootstrap adds the passed Unstructured object to the MachinePoolBuilder as a bootstrap. +func (m *MachinePoolBuilder) WithBootstrap(ref *unstructured.Unstructured) *MachinePoolBuilder { + m.bootstrap = ref return m } -// WithInfrastructureTemplate adds the passed unstructured object to the MachinePool builder as an infrastructureMachineTemplate. -func (m *MachinePoolBuilder) WithInfrastructureTemplate(ref *unstructured.Unstructured) *MachinePoolBuilder { - m.infrastructureTemplate = ref +// WithInfrastructure adds the passed Unstructured object to the MachinePool builder as an InfrastructureMachinePool. +func (m *MachinePoolBuilder) WithInfrastructure(ref *unstructured.Unstructured) *MachinePoolBuilder { + m.infrastructure = ref return m } @@ -1122,11 +1518,11 @@ func (m *MachinePoolBuilder) Build() *expv1.MachinePool { Replicas: m.replicas, }, } - if m.bootstrapTemplate != nil { - obj.Spec.Template.Spec.Bootstrap.ConfigRef = objToRef(m.bootstrapTemplate) + if m.bootstrap != nil { + obj.Spec.Template.Spec.Bootstrap.ConfigRef = objToRef(m.bootstrap) } - if m.infrastructureTemplate != nil { - obj.Spec.Template.Spec.InfrastructureRef = *objToRef(m.infrastructureTemplate) + if m.infrastructure != nil { + obj.Spec.Template.Spec.InfrastructureRef = *objToRef(m.infrastructure) } if m.version != nil { obj.Spec.Template.Spec.Version = m.version diff --git a/internal/test/builder/infrastructure.go b/internal/test/builder/infrastructure.go index 8fdb9617d97b..8e0d78e197e5 100644 --- a/internal/test/builder/infrastructure.go +++ b/internal/test/builder/infrastructure.go @@ -35,6 +35,12 @@ var ( // GenericInfrastructureMachineTemplateCRD is a generic infrastructure machine template CRD. GenericInfrastructureMachineTemplateCRD = untypedCRD(InfrastructureGroupVersion.WithKind(GenericInfrastructureMachineTemplateKind)) + // GenericInfrastructureMachinePoolTemplateKind is the Kind for the GenericInfrastructureMachinePoolTemplate. + GenericInfrastructureMachinePoolTemplateKind = "GenericInfrastructureMachinePoolTemplate" + + // GenericInfrastructureMachinePoolKind is the Kind for the GenericInfrastructureMachinePool. + GenericInfrastructureMachinePoolKind = "GenericInfrastructureMachinePool" + // GenericInfrastructureClusterKind is the kind for the GenericInfrastructureCluster type. GenericInfrastructureClusterKind = "GenericInfrastructureCluster" // GenericInfrastructureClusterCRD is a generic infrastructure machine CRD. @@ -62,6 +68,12 @@ var ( // TestInfrastructureMachineTemplateCRD is a test infrastructure machine template CRD. TestInfrastructureMachineTemplateCRD = testInfrastructureMachineTemplateCRD(InfrastructureGroupVersion.WithKind(TestInfrastructureMachineTemplateKind)) + // TestInfrastructureMachinePoolTemplateKind is the kind for the TestInfrastructureMachinePoolTemplate type. + TestInfrastructureMachinePoolTemplateKind = "TestInfrastructureMachinePoolTemplate" + + // TestInfrastructureMachinePoolKind is the kind for the TestInfrastructureMachinePool type. + TestInfrastructureMachinePoolKind = "TestInfrastructureMachinePool" + // TestInfrastructureMachineKind is the kind for the TestInfrastructureMachine type. TestInfrastructureMachineKind = "TestInfrastructureMachine" // TestInfrastructureMachineCRD is a test infrastructure machine CRD. diff --git a/internal/test/builder/zz_generated.deepcopy.go b/internal/test/builder/zz_generated.deepcopy.go index ad2f6659f99c..c6a1e986ca36 100644 --- a/internal/test/builder/zz_generated.deepcopy.go +++ b/internal/test/builder/zz_generated.deepcopy.go @@ -27,6 +27,25 @@ import ( apiv1beta1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BootstrapConfigBuilder) DeepCopyInto(out *BootstrapConfigBuilder) { + *out = *in + if in.obj != nil { + in, out := &in.obj, &out.obj + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BootstrapConfigBuilder. +func (in *BootstrapConfigBuilder) DeepCopy() *BootstrapConfigBuilder { + if in == nil { + return nil + } + out := new(BootstrapConfigBuilder) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BootstrapTemplateBuilder) DeepCopyInto(out *BootstrapTemplateBuilder) { *out = *in @@ -140,6 +159,13 @@ func (in *ClusterClassBuilder) DeepCopyInto(out *ClusterClassBuilder) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.machinePoolClasses != nil { + in, out := &in.machinePoolClasses, &out.machinePoolClasses + *out = make([]v1beta1.MachinePoolClass, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } if in.variables != nil { in, out := &in.variables, &out.variables *out = make([]v1beta1.ClusterClassVariable, len(*in)) @@ -281,6 +307,44 @@ func (in *InfrastructureClusterTemplateBuilder) DeepCopy() *InfrastructureCluste return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InfrastructureMachinePoolBuilder) DeepCopyInto(out *InfrastructureMachinePoolBuilder) { + *out = *in + if in.obj != nil { + in, out := &in.obj, &out.obj + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InfrastructureMachinePoolBuilder. +func (in *InfrastructureMachinePoolBuilder) DeepCopy() *InfrastructureMachinePoolBuilder { + if in == nil { + return nil + } + out := new(InfrastructureMachinePoolBuilder) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InfrastructureMachinePoolTemplateBuilder) DeepCopyInto(out *InfrastructureMachinePoolTemplateBuilder) { + *out = *in + if in.obj != nil { + in, out := &in.obj, &out.obj + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InfrastructureMachinePoolTemplateBuilder. +func (in *InfrastructureMachinePoolTemplateBuilder) DeepCopy() *InfrastructureMachinePoolTemplateBuilder { + if in == nil { + return nil + } + out := new(InfrastructureMachinePoolTemplateBuilder) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InfrastructureMachineTemplateBuilder) DeepCopyInto(out *InfrastructureMachineTemplateBuilder) { *out = *in @@ -526,12 +590,12 @@ func (in *MachineHealthCheckBuilder) DeepCopy() *MachineHealthCheckBuilder { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachinePoolBuilder) DeepCopyInto(out *MachinePoolBuilder) { *out = *in - if in.bootstrapTemplate != nil { - in, out := &in.bootstrapTemplate, &out.bootstrapTemplate + if in.bootstrap != nil { + in, out := &in.bootstrap, &out.bootstrap *out = (*in).DeepCopy() } - if in.infrastructureTemplate != nil { - in, out := &in.infrastructureTemplate, &out.infrastructureTemplate + if in.infrastructure != nil { + in, out := &in.infrastructure, &out.infrastructure *out = (*in).DeepCopy() } if in.version != nil { @@ -568,6 +632,100 @@ func (in *MachinePoolBuilder) DeepCopy() *MachinePoolBuilder { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachinePoolClassBuilder) DeepCopyInto(out *MachinePoolClassBuilder) { + *out = *in + if in.infrastructureMachinePoolTemplate != nil { + in, out := &in.infrastructureMachinePoolTemplate, &out.infrastructureMachinePoolTemplate + *out = (*in).DeepCopy() + } + if in.bootstrapTemplate != nil { + in, out := &in.bootstrapTemplate, &out.bootstrapTemplate + *out = (*in).DeepCopy() + } + if in.labels != nil { + in, out := &in.labels, &out.labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.annotations != nil { + in, out := &in.annotations, &out.annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.failureDomains != nil { + in, out := &in.failureDomains, &out.failureDomains + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.nodeDrainTimeout != nil { + in, out := &in.nodeDrainTimeout, &out.nodeDrainTimeout + *out = new(v1.Duration) + **out = **in + } + if in.nodeVolumeDetachTimeout != nil { + in, out := &in.nodeVolumeDetachTimeout, &out.nodeVolumeDetachTimeout + *out = new(v1.Duration) + **out = **in + } + if in.nodeDeletionTimeout != nil { + in, out := &in.nodeDeletionTimeout, &out.nodeDeletionTimeout + *out = new(v1.Duration) + **out = **in + } + if in.minReadySeconds != nil { + in, out := &in.minReadySeconds, &out.minReadySeconds + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachinePoolClassBuilder. +func (in *MachinePoolClassBuilder) DeepCopy() *MachinePoolClassBuilder { + if in == nil { + return nil + } + out := new(MachinePoolClassBuilder) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachinePoolTopologyBuilder) DeepCopyInto(out *MachinePoolTopologyBuilder) { + *out = *in + if in.replicas != nil { + in, out := &in.replicas, &out.replicas + *out = new(int32) + **out = **in + } + if in.failureDomains != nil { + in, out := &in.failureDomains, &out.failureDomains + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.variables != nil { + in, out := &in.variables, &out.variables + *out = make([]v1beta1.ClusterVariable, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachinePoolTopologyBuilder. +func (in *MachinePoolTopologyBuilder) DeepCopy() *MachinePoolTopologyBuilder { + if in == nil { + return nil + } + out := new(MachinePoolTopologyBuilder) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineSetBuilder) DeepCopyInto(out *MachineSetBuilder) { *out = *in @@ -610,6 +768,25 @@ func (in *MachineSetBuilder) DeepCopy() *MachineSetBuilder { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestBootstrapConfigBuilder) DeepCopyInto(out *TestBootstrapConfigBuilder) { + *out = *in + if in.obj != nil { + in, out := &in.obj, &out.obj + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestBootstrapConfigBuilder. +func (in *TestBootstrapConfigBuilder) DeepCopy() *TestBootstrapConfigBuilder { + if in == nil { + return nil + } + out := new(TestBootstrapConfigBuilder) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TestBootstrapTemplateBuilder) DeepCopyInto(out *TestBootstrapTemplateBuilder) { *out = *in @@ -705,6 +882,44 @@ func (in *TestInfrastructureClusterTemplateBuilder) DeepCopy() *TestInfrastructu return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestInfrastructureMachinePoolBuilder) DeepCopyInto(out *TestInfrastructureMachinePoolBuilder) { + *out = *in + if in.obj != nil { + in, out := &in.obj, &out.obj + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestInfrastructureMachinePoolBuilder. +func (in *TestInfrastructureMachinePoolBuilder) DeepCopy() *TestInfrastructureMachinePoolBuilder { + if in == nil { + return nil + } + out := new(TestInfrastructureMachinePoolBuilder) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestInfrastructureMachinePoolTemplateBuilder) DeepCopyInto(out *TestInfrastructureMachinePoolTemplateBuilder) { + *out = *in + if in.obj != nil { + in, out := &in.obj, &out.obj + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestInfrastructureMachinePoolTemplateBuilder. +func (in *TestInfrastructureMachinePoolTemplateBuilder) DeepCopy() *TestInfrastructureMachinePoolTemplateBuilder { + if in == nil { + return nil + } + out := new(TestInfrastructureMachinePoolTemplateBuilder) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TestInfrastructureMachineTemplateBuilder) DeepCopyInto(out *TestInfrastructureMachineTemplateBuilder) { *out = *in