Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 870884b

Browse files
committed
fix: set defaults and validation
1 parent a952c7a commit 870884b

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

api/v1alpha1/common_types.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33

44
package v1alpha1
55

6-
import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
6+
import (
7+
"k8s.io/utils/ptr"
8+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
9+
10+
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/variables"
11+
)
12+
13+
const (
14+
APIServerPort = 6443
15+
)
716

817
// ObjectMeta is metadata that all persisted resources must have, which includes all objects
918
// users must create. This is a copy of customizable fields from metav1.ObjectMeta.
@@ -31,18 +40,23 @@ type ControlPlaneEndpointSpec clusterv1.APIEndpoint
3140
func (ControlPlaneEndpointSpec) VariableSchema() clusterv1.VariableSchema {
3241
return clusterv1.VariableSchema{
3342
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
34-
Description: "Nutanix control-plane endpoint configuration",
43+
Description: "Kubernetes control-plane endpoint configuration",
3544
Type: "object",
3645
Properties: map[string]clusterv1.JSONSchemaProps{
3746
"host": {
3847
Description: "host ip/fqdn for control plane API Server",
3948
Type: "string",
49+
MinLength: ptr.To[int64](1),
4050
},
4151
"port": {
4252
Description: "port for control plane API Server",
4353
Type: "integer",
54+
Default: variables.MustMarshal(APIServerPort),
55+
Minimum: ptr.To[int64](1),
56+
Maximum: ptr.To[int64](65535),
4457
},
4558
},
59+
Required: []string{"host", "port"},
4660
},
4761
}
4862
}

api/v1alpha1/nutanix_clusterconfig_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ package v1alpha1
55

66
import (
77
corev1 "k8s.io/api/core/v1"
8+
"k8s.io/utils/ptr"
89
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
10+
11+
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/variables"
12+
)
13+
14+
const (
15+
PrismCentralPort = 9440
916
)
1017

1118
// NutanixSpec defines the desired state of NutanixCluster.
@@ -61,10 +68,14 @@ func (NutanixPrismCentralEndpointSpec) VariableSchema() clusterv1.VariableSchema
6168
"address": {
6269
Description: "the endpoint address (DNS name or IP address) of the Nutanix Prism Central",
6370
Type: "string",
71+
MinLength: ptr.To[int64](1),
6472
},
6573
"port": {
6674
Description: "The port number to access the Nutanix Prism Central",
6775
Type: "integer",
76+
Default: variables.MustMarshal(PrismCentralPort),
77+
Minimum: ptr.To[int64](1),
78+
Maximum: ptr.To[int64](65535),
6879
},
6980
"insecure": {
7081
Description: "Use insecure connection to Prism Central endpoint",

0 commit comments

Comments
 (0)