Skip to content

Commit 8cef217

Browse files
Revert "removed optional annotation from non-optional fields (#400)" (#414)
This reverts commit f6e079c.
1 parent f6e079c commit 8cef217

File tree

6 files changed

+18
-20
lines changed

6 files changed

+18
-20
lines changed

api/v1beta1/nutanixcluster_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ type NutanixClusterSpec struct {
4646

4747
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
4848
// host can be either DNS name or ip address
49+
// +optional
4950
ControlPlaneEndpoint capiv1.APIEndpoint `json:"controlPlaneEndpoint"`
5051

5152
// prismCentral holds the endpoint address and port to access the Nutanix Prism Central.
5253
// When a cluster-wide proxy is installed, by default, this endpoint will be accessed via the proxy.
5354
// Should you wish for communication with this endpoint not to be proxied, please add the endpoint to the
5455
// proxy spec.noProxy list.
56+
// +optional
5557
PrismCentral *credentialTypes.NutanixPrismEndpoint `json:"prismCentral"`
5658

5759
// failureDomains configures failure domains information for the Nutanix platform.
@@ -60,7 +62,7 @@ type NutanixClusterSpec struct {
6062
// +listType=map
6163
// +listMapKey=name
6264
// +optional
63-
FailureDomains []NutanixFailureDomain `json:"failureDomains,omitempty"`
65+
FailureDomains []NutanixFailureDomain `json:"failureDomains"`
6466
}
6567

6668
// NutanixClusterStatus defines the observed state of NutanixCluster

api/v1beta1/nutanixmachine_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ type NutanixMachineSpec struct {
8383
Subnets []NutanixResourceIdentifier `json:"subnet"`
8484
// List of categories that need to be added to the machines. Categories must already exist in Prism Central
8585
// +kubebuilder:validation:Optional
86-
// +optional
8786
AdditionalCategories []NutanixCategoryIdentifier `json:"additionalCategories,omitempty"`
8887
// Add the machine resources to a Prism Central project
8988
// +optional
@@ -105,7 +104,6 @@ type NutanixMachineSpec struct {
105104

106105
// List of GPU devices that need to be added to the machines.
107106
// +kubebuilder:validation:Optional
108-
// +optional
109107
GPUs []NutanixGPU `json:"gpus,omitempty"`
110108
}
111109

config/crd/bases/infrastructure.cluster.x-k8s.io_nutanixclusters.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,6 @@ spec:
512512
- address
513513
- port
514514
type: object
515-
required:
516-
- controlPlaneEndpoint
517-
- prismCentral
518515
type: object
519516
status:
520517
description: NutanixClusterStatus defines the observed state of NutanixCluster

config/crd/bases/infrastructure.cluster.x-k8s.io_nutanixclustertemplates.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,6 @@ spec:
228228
- address
229229
- port
230230
type: object
231-
required:
232-
- controlPlaneEndpoint
233-
- prismCentral
234231
type: object
235232
required:
236233
- spec

controllers/helpers_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
credentialTypes "github.com/nutanix-cloud-native/prism-go-client/environment/credentials"
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25-
capiv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2625
"sigs.k8s.io/cluster-api/util"
2726

2827
infrav1 "github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1"
@@ -53,7 +52,6 @@ func TestControllerHelpers(t *testing.T) {
5352
Namespace: "default",
5453
},
5554
Spec: infrav1.NutanixClusterSpec{
56-
ControlPlaneEndpoint: capiv1.APIEndpoint{},
5755
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
5856
// Adding port info to override default value (0)
5957
Port: 9440,

controllers/nutanixcluster_controller_test.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ func TestNutanixClusterReconciler(t *testing.T) {
8383
UID: utilruntime.NewUUID(),
8484
},
8585
Spec: infrav1.NutanixClusterSpec{
86-
ControlPlaneEndpoint: capiv1.APIEndpoint{},
8786
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
8887
// Adding port info to override default value (0)
8988
Port: 9440,
@@ -246,7 +245,6 @@ func TestNutanixClusterReconciler(t *testing.T) {
246245
Namespace: corev1.NamespaceDefault,
247246
},
248247
Spec: infrav1.NutanixClusterSpec{
249-
ControlPlaneEndpoint: capiv1.APIEndpoint{},
250248
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
251249
// Adding port info to override default value (0)
252250
Port: 9440,
@@ -411,7 +409,6 @@ func TestNutanixClusterReconciler(t *testing.T) {
411409
Namespace: "default",
412410
},
413411
Spec: infrav1.NutanixClusterSpec{
414-
ControlPlaneEndpoint: capiv1.APIEndpoint{},
415412
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
416413
// Adding port info to override default value (0)
417414
Port: 9440,
@@ -474,7 +471,6 @@ func TestNutanixClusterReconciler(t *testing.T) {
474471
Namespace: "default",
475472
},
476473
Spec: infrav1.NutanixClusterSpec{
477-
ControlPlaneEndpoint: capiv1.APIEndpoint{},
478474
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
479475
// Adding port info to override default value (0)
480476
Port: 9440,
@@ -509,7 +505,6 @@ func TestNutanixClusterReconciler(t *testing.T) {
509505
Namespace: "default",
510506
},
511507
Spec: infrav1.NutanixClusterSpec{
512-
ControlPlaneEndpoint: capiv1.APIEndpoint{},
513508
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
514509
// Adding port info to override default value (0)
515510
Port: 9440,
@@ -535,23 +530,34 @@ func TestNutanixClusterReconciler(t *testing.T) {
535530
})
536531
})
537532

538-
Context("NutanixCluster creation failed: PrismCentral Info is null", func() {
533+
Context("Delete credentials ref reconcile failed: PrismCentral Info is null", func() {
539534
It("Should not return error", func() {
540535
ctx := context.Background()
536+
reconciler := &NutanixClusterReconciler{
537+
Client: k8sClient,
538+
Scheme: runtime.NewScheme(),
539+
}
541540

542541
ntnxCluster := &infrav1.NutanixCluster{
543542
ObjectMeta: metav1.ObjectMeta{
544543
Name: "test",
545544
Namespace: "default",
546545
},
547546
Spec: infrav1.NutanixClusterSpec{
548-
ControlPlaneEndpoint: capiv1.APIEndpoint{},
549-
PrismCentral: nil,
547+
PrismCentral: nil,
550548
},
551549
}
552550

553551
// Create the NutanixCluster object
554-
g.Expect(k8sClient.Create(ctx, ntnxCluster)).NotTo(Succeed())
552+
g.Expect(k8sClient.Create(ctx, ntnxCluster)).To(Succeed())
553+
defer func() {
554+
err := k8sClient.Delete(ctx, ntnxCluster)
555+
Expect(err).NotTo(HaveOccurred())
556+
}()
557+
558+
// Reconile Delete credential ref
559+
err := reconciler.reconcileCredentialRefDelete(ctx, ntnxCluster)
560+
g.Expect(err).NotTo(HaveOccurred())
555561
})
556562
})
557563
})

0 commit comments

Comments
 (0)