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

Commit

Permalink
fix: set defaults and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoshkin committed Apr 1, 2024
1 parent a952c7a commit 870884b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
18 changes: 16 additions & 2 deletions api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@

package v1alpha1

import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
import (
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/variables"
)

const (
APIServerPort = 6443
)

// ObjectMeta is metadata that all persisted resources must have, which includes all objects
// users must create. This is a copy of customizable fields from metav1.ObjectMeta.
Expand Down Expand Up @@ -31,18 +40,23 @@ type ControlPlaneEndpointSpec clusterv1.APIEndpoint
func (ControlPlaneEndpointSpec) VariableSchema() clusterv1.VariableSchema {
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Description: "Nutanix control-plane endpoint configuration",
Description: "Kubernetes control-plane endpoint configuration",
Type: "object",
Properties: map[string]clusterv1.JSONSchemaProps{
"host": {
Description: "host ip/fqdn for control plane API Server",
Type: "string",
MinLength: ptr.To[int64](1),
},
"port": {
Description: "port for control plane API Server",
Type: "integer",
Default: variables.MustMarshal(APIServerPort),
Minimum: ptr.To[int64](1),
Maximum: ptr.To[int64](65535),
},
},
Required: []string{"host", "port"},
},
}
}
11 changes: 11 additions & 0 deletions api/v1alpha1/nutanix_clusterconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/variables"
)

const (
PrismCentralPort = 9440
)

// NutanixSpec defines the desired state of NutanixCluster.
Expand Down Expand Up @@ -61,10 +68,14 @@ func (NutanixPrismCentralEndpointSpec) VariableSchema() clusterv1.VariableSchema
"address": {
Description: "the endpoint address (DNS name or IP address) of the Nutanix Prism Central",
Type: "string",
MinLength: ptr.To[int64](1),
},
"port": {
Description: "The port number to access the Nutanix Prism Central",
Type: "integer",
Default: variables.MustMarshal(PrismCentralPort),
Minimum: ptr.To[int64](1),
Maximum: ptr.To[int64](65535),
},
"insecure": {
Description: "Use insecure connection to Prism Central endpoint",
Expand Down

0 comments on commit 870884b

Please sign in to comment.