Skip to content

Commit fd42497

Browse files
committed
feat: Make the Nutanix top-level node specs required
1 parent bab9a86 commit fd42497

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
lines changed

api/v1alpha1/controlplane_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type DockerControlPlaneSpec struct {
3131

3232
// NutanixControlPlaneSpec defines the desired state of the control plane for a Nutanix cluster.
3333
type NutanixControlPlaneSpec struct {
34-
// +kubebuilder:validation:Optional
34+
// +kubebuilder:validation:Required
3535
Nutanix *NutanixControlPlaneNodeSpec `json:"nutanix,omitempty"`
3636

3737
GenericControlPlaneSpec `json:",inline"`

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ spec:
341341
type: array
342342
x-kubernetes-list-type: set
343343
machineDetails:
344+
description: machineDetails specifies the details of the Nutanix machine that will be created
344345
properties:
345346
additionalCategories:
346347
description: |-
@@ -553,6 +554,8 @@ spec:
553554
- key
554555
type: object
555556
type: array
557+
required:
558+
- nutanix
556559
type: object
557560
dns:
558561
description: DNS defines the DNS configuration for the cluster.

api/v1alpha1/crds/caren.nutanix.com_nutanixworkernodeconfigs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ spec:
6161
nutanix:
6262
properties:
6363
machineDetails:
64+
description: machineDetails specifies the details of the Nutanix machine that will be created
6465
properties:
6566
additionalCategories:
6667
description: |-
@@ -273,6 +274,8 @@ spec:
273274
- key
274275
type: object
275276
type: array
277+
required:
278+
- nutanix
276279
type: object
277280
type: object
278281
served: true

api/v1alpha1/nodeconfig_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (s NutanixWorkerNodeConfig) VariableSchema() clusterv1.VariableSchema { //n
9696

9797
// NutanixWorkerNodeConfigSpec defines the desired state of NutanixWorkerNodeSpec.
9898
type NutanixWorkerNodeConfigSpec struct {
99-
// +kubebuilder:validation:Optional
99+
// +kubebuilder:validation:Required
100100
Nutanix *NutanixWorkerNodeSpec `json:"nutanix,omitempty"`
101101

102102
GenericNodeSpec `json:",inline"`

api/v1alpha1/nutanix_node_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
)
1111

1212
type NutanixControlPlaneNodeSpec struct {
13+
// machineDetails specifies the details of the Nutanix machine that will be created
14+
// +kubebuilder:validation:Required
1315
MachineDetails NutanixMachineDetails `json:"machineDetails"`
1416

1517
// failureDomains specifies a list of NutanixFailureDomains (by names)
@@ -20,6 +22,8 @@ type NutanixControlPlaneNodeSpec struct {
2022
}
2123

2224
type NutanixWorkerNodeSpec struct {
25+
// machineDetails specifies the details of the Nutanix machine that will be created
26+
// +kubebuilder:validation:Required
2327
MachineDetails NutanixMachineDetails `json:"machineDetails"`
2428
}
2529

pkg/handlers/generic/mutation/autorenewcerts/variables_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ package autorenewcerts
66
import (
77
"testing"
88

9+
"k8s.io/apimachinery/pkg/api/resource"
910
"k8s.io/utils/ptr"
1011

12+
capxv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1"
1113
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
1214
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation"
1315
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest"
@@ -20,6 +22,7 @@ var nutanixTestDefs = []capitest.VariableTestDef{
2022
Vals: v1alpha1.NutanixClusterConfigSpec{
2123
ControlPlane: &v1alpha1.NutanixControlPlaneSpec{
2224
GenericControlPlaneSpec: v1alpha1.GenericControlPlaneSpec{},
25+
Nutanix: minimalNutanixControlPlaneNodeSpec(),
2326
},
2427
},
2528
},
@@ -32,6 +35,7 @@ var nutanixTestDefs = []capitest.VariableTestDef{
3235
DaysBeforeExpiry: 0,
3336
},
3437
},
38+
Nutanix: minimalNutanixControlPlaneNodeSpec(),
3539
},
3640
},
3741
},
@@ -44,6 +48,7 @@ var nutanixTestDefs = []capitest.VariableTestDef{
4448
DaysBeforeExpiry: 7,
4549
},
4650
},
51+
Nutanix: minimalNutanixControlPlaneNodeSpec(),
4752
},
4853
},
4954
},
@@ -56,6 +61,7 @@ var nutanixTestDefs = []capitest.VariableTestDef{
5661
DaysBeforeExpiry: 1,
5762
},
5863
},
64+
Nutanix: minimalNutanixControlPlaneNodeSpec(),
5965
},
6066
},
6167
ExpectError: true,
@@ -74,3 +80,30 @@ func TestVariableValidation_Nutanix(t *testing.T) {
7480
nutanixTestDefs...,
7581
)
7682
}
83+
84+
func minimalNutanixControlPlaneNodeSpec() *v1alpha1.NutanixControlPlaneNodeSpec {
85+
return &v1alpha1.NutanixControlPlaneNodeSpec{
86+
MachineDetails: v1alpha1.NutanixMachineDetails{
87+
BootType: capxv1.NutanixBootTypeLegacy,
88+
VCPUSockets: 2,
89+
VCPUsPerSocket: 1,
90+
Image: &capxv1.NutanixResourceIdentifier{
91+
Type: capxv1.NutanixIdentifierName,
92+
Name: ptr.To("fake-image"),
93+
},
94+
ImageLookup: nil,
95+
Cluster: &capxv1.NutanixResourceIdentifier{
96+
Type: capxv1.NutanixIdentifierName,
97+
Name: ptr.To("fake-pe-cluster"),
98+
},
99+
MemorySize: resource.MustParse("8Gi"),
100+
SystemDiskSize: resource.MustParse("40Gi"),
101+
Subnets: []capxv1.NutanixResourceIdentifier{
102+
{
103+
Type: capxv1.NutanixIdentifierName,
104+
Name: ptr.To("fake-subnet"),
105+
},
106+
},
107+
},
108+
}
109+
}

0 commit comments

Comments
 (0)