Skip to content

Commit 1bc0d50

Browse files
committed
removed optional annotation from non-optional fields
same code as https://github.com/nutanix-cloud-native/cluster-api-provider-nutanix/pull/400/files which was reverted in #414
1 parent 8228f42 commit 1bc0d50

File tree

10 files changed

+46
-24
lines changed

10 files changed

+46
-24
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ cluster-templates: ## Generate cluster templates for all flavors
286286
.PHONY: docker-build-e2e
287287
docker-build-e2e: ## Build docker image with the manager with e2e tag.
288288
echo "Git commit hash: ${GIT_COMMIT_HASH}"
289-
KO_DOCKER_REPO=ko.local GOFLAGS="-ldflags=-X=main.gitCommitHash=${GIT_COMMIT_HASH}" ko build -B --platform=${PLATFORMS_E2E} -t ${IMG_TAG} -L .
289+
KO_DOCKER_REPO=ko.local GOFLAGS="-ldflags=-X=main.gitCommitHash=${GIT_COMMIT_HASH}" ko build -B --platform=${PLATFORMS_E2E} -t ${IMG_TAG} .
290290
docker tag ko.local/cluster-api-provider-nutanix:${IMG_TAG} ${IMG_REPO}:e2e
291291

292292
.PHONY: prepare-local-clusterctl
@@ -333,7 +333,7 @@ test-e2e: docker-build-e2e cluster-e2e-templates cluster-templates ## Run the en
333333
mkdir -p $(ARTIFACTS)
334334
NUTANIX_LOG_LEVEL=debug ginkgo -v \
335335
--trace \
336-
--progress \
336+
--show-node-events \
337337
--tags=e2e \
338338
--label-filter=$(LABEL_FILTER_ARGS) \
339339
$(_SKIP_ARGS) \
@@ -343,7 +343,7 @@ test-e2e: docker-build-e2e cluster-e2e-templates cluster-templates ## Run the en
343343
--output-dir="$(ARTIFACTS)" \
344344
--junit-report=${JUNIT_REPORT_FILE} \
345345
--timeout="24h" \
346-
--always-emit-ginkgo-writer \
346+
-v \
347347
$(GINKGO_ARGS) ./test/e2e -- \
348348
-e2e.artifacts-folder="$(ARTIFACTS)" \
349349
-e2e.config="$(E2E_CONF_FILE)" \
@@ -355,7 +355,7 @@ test-e2e-no-kubeproxy: docker-build-e2e cluster-e2e-templates-no-kubeproxy clust
355355
mkdir -p $(ARTIFACTS)
356356
NUTANIX_LOG_LEVEL=debug ginkgo -v \
357357
--trace \
358-
--progress \
358+
--show-node-events \
359359
--tags=e2e \
360360
--label-filter=$(LABEL_FILTER_ARGS) \
361361
$(_SKIP_ARGS) \
@@ -364,7 +364,7 @@ test-e2e-no-kubeproxy: docker-build-e2e cluster-e2e-templates-no-kubeproxy clust
364364
--output-dir="$(ARTIFACTS)" \
365365
--junit-report=${JUNIT_REPORT_FILE} \
366366
--timeout="24h" \
367-
--always-emit-ginkgo-writer \
367+
-v \
368368
$(GINKGO_ARGS) ./test/e2e -- \
369369
-e2e.artifacts-folder="$(ARTIFACTS)" \
370370
-e2e.config="$(E2E_CONF_FILE)" \

api/v1beta1/nutanixcluster_types.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ 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
5049
ControlPlaneEndpoint capiv1.APIEndpoint `json:"controlPlaneEndpoint"`
5150

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

5957
// failureDomains configures failure domains information for the Nutanix platform.
@@ -62,7 +60,7 @@ type NutanixClusterSpec struct {
6260
// +listType=map
6361
// +listMapKey=name
6462
// +optional
65-
FailureDomains []NutanixFailureDomain `json:"failureDomains"`
63+
FailureDomains []NutanixFailureDomain `json:"failureDomains,omitempty"`
6664
}
6765

6866
// NutanixClusterStatus defines the observed state of NutanixCluster

api/v1beta1/nutanixmachine_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ 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
8687
AdditionalCategories []NutanixCategoryIdentifier `json:"additionalCategories,omitempty"`
8788
// Add the machine resources to a Prism Central project
8889
// +optional
@@ -104,6 +105,7 @@ type NutanixMachineSpec struct {
104105

105106
// List of GPU devices that need to be added to the machines.
106107
// +kubebuilder:validation:Optional
108+
// +optional
107109
GPUs []NutanixGPU `json:"gpus,omitempty"`
108110
}
109111

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

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

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

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

controllers/helpers_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ 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"
2526
"sigs.k8s.io/cluster-api/util"
2627

2728
infrav1 "github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1"
@@ -52,6 +53,7 @@ func TestControllerHelpers(t *testing.T) {
5253
Namespace: "default",
5354
},
5455
Spec: infrav1.NutanixClusterSpec{
56+
ControlPlaneEndpoint: capiv1.APIEndpoint{},
5557
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
5658
// Adding port info to override default value (0)
5759
Port: 9440,

controllers/nutanixcluster_controller_test.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func TestNutanixClusterReconciler(t *testing.T) {
8383
UID: utilruntime.NewUUID(),
8484
},
8585
Spec: infrav1.NutanixClusterSpec{
86+
ControlPlaneEndpoint: capiv1.APIEndpoint{},
8687
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
8788
// Adding port info to override default value (0)
8889
Port: 9440,
@@ -245,6 +246,7 @@ func TestNutanixClusterReconciler(t *testing.T) {
245246
Namespace: corev1.NamespaceDefault,
246247
},
247248
Spec: infrav1.NutanixClusterSpec{
249+
ControlPlaneEndpoint: capiv1.APIEndpoint{},
248250
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
249251
// Adding port info to override default value (0)
250252
Port: 9440,
@@ -409,6 +411,7 @@ func TestNutanixClusterReconciler(t *testing.T) {
409411
Namespace: "default",
410412
},
411413
Spec: infrav1.NutanixClusterSpec{
414+
ControlPlaneEndpoint: capiv1.APIEndpoint{},
412415
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
413416
// Adding port info to override default value (0)
414417
Port: 9440,
@@ -471,6 +474,7 @@ func TestNutanixClusterReconciler(t *testing.T) {
471474
Namespace: "default",
472475
},
473476
Spec: infrav1.NutanixClusterSpec{
477+
ControlPlaneEndpoint: capiv1.APIEndpoint{},
474478
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
475479
// Adding port info to override default value (0)
476480
Port: 9440,
@@ -505,6 +509,7 @@ func TestNutanixClusterReconciler(t *testing.T) {
505509
Namespace: "default",
506510
},
507511
Spec: infrav1.NutanixClusterSpec{
512+
ControlPlaneEndpoint: capiv1.APIEndpoint{},
508513
PrismCentral: &credentialTypes.NutanixPrismEndpoint{
509514
// Adding port info to override default value (0)
510515
Port: 9440,
@@ -530,34 +535,23 @@ func TestNutanixClusterReconciler(t *testing.T) {
530535
})
531536
})
532537

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

541542
ntnxCluster := &infrav1.NutanixCluster{
542543
ObjectMeta: metav1.ObjectMeta{
543544
Name: "test",
544545
Namespace: "default",
545546
},
546547
Spec: infrav1.NutanixClusterSpec{
547-
PrismCentral: nil,
548+
ControlPlaneEndpoint: capiv1.APIEndpoint{},
549+
PrismCentral: nil,
548550
},
549551
}
550552

551553
// Create the NutanixCluster object
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())
554+
g.Expect(k8sClient.Create(ctx, ntnxCluster)).NotTo(Succeed())
561555
})
562556
})
563557
})

templates/cluster-template-clusterclass.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,17 @@ metadata:
699699
spec:
700700
template:
701701
spec:
702+
controlPlaneEndpoint:
703+
host: PLACEHOLDER
704+
port: 6443
702705
failureDomains: []
706+
prismCentral:
707+
address: PLACEHOLDER
708+
credentialRef:
709+
kind: Secret
710+
name: PLACEHOLDER
711+
namespace: default
712+
port: 9440
703713
---
704714
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
705715
kind: NutanixMachineTemplate

templates/clusterclass/nct.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,14 @@ metadata:
55
spec:
66
template:
77
spec:
8+
controlPlaneEndpoint:
9+
host: PLACEHOLDER
10+
port: 6443
11+
prismCentral:
12+
address: PLACEHOLDER
13+
port: 9440
14+
credentialRef:
15+
name: PLACEHOLDER
16+
kind: Secret
17+
namespace: default
818
failureDomains: []

test/e2e/config/nutanix.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ variables:
244244
CONTROL_PLANE_MACHINE_COUNT: 3
245245
WORKER_MACHINE_COUNT: 3
246246
NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: ""
247-
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: "ubuntu-2004-kube-v1.29.2.qcow2"
247+
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: "ubuntu-2204-kube-v1.29.2.qcow2"
248248
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_26: "ubuntu-2204-kube-v1.26.13.qcow2"
249249
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27: "ubuntu-2204-kube-v1.27.9.qcow2"
250250
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_28: "ubuntu-2204-kube-v1.28.6.qcow2"

0 commit comments

Comments
 (0)