|
| 1 | +// Copyright 2024 D2iQ, Inc. All rights reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +package v1alpha1 |
| 5 | + |
| 6 | +import ( |
| 7 | + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" |
| 8 | +) |
| 9 | + |
| 10 | +type NutanixSpec struct { |
| 11 | + PrismCentralEndpoint *NutanixPrismCentralEndpointSpec `json:"prismCentralEndpoint,omitempty"` |
| 12 | + ControlPlaneEndpoint *NutanixControlPlaneEndpointSpec `json:"controlPlaneEndpoint,omitempty"` |
| 13 | + FailureDomains []NutanixFailureDomain `json:"failureDomains,omitempty"` |
| 14 | +} |
| 15 | + |
| 16 | +func (NutanixSpec) VariableSchema() clusterv1.VariableSchema { |
| 17 | + return clusterv1.VariableSchema{ |
| 18 | + OpenAPIV3Schema: clusterv1.JSONSchemaProps{ |
| 19 | + Description: "Nutanix cluster configuration", |
| 20 | + Type: "object", |
| 21 | + Properties: map[string]clusterv1.JSONSchemaProps{ |
| 22 | + "prismCentralEndpoint": NutanixPrismCentralEndpointSpec{}.VariableSchema().OpenAPIV3Schema, |
| 23 | + "controlPlaneEndpoint": NutanixControlPlaneEndpointSpec{}.VariableSchema().OpenAPIV3Schema, |
| 24 | + "failureDomains": NutanixFailureDomains{}.VariableSchema().OpenAPIV3Schema, |
| 25 | + }, |
| 26 | + }, |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +type NutanixPrismCentralEndpointSpec struct { |
| 31 | + Host string `json:"host"` |
| 32 | + Port int32 `json:"port"` |
| 33 | + Insecure bool `json:"insecure"` |
| 34 | + AdditionalTrustBundle string `json:"additionalTrustBundle,omitempty"` |
| 35 | + CredentialSecret string `json:"credentialSecret"` |
| 36 | +} |
| 37 | + |
| 38 | +func (NutanixPrismCentralEndpointSpec) VariableSchema() clusterv1.VariableSchema { |
| 39 | + return clusterv1.VariableSchema{ |
| 40 | + OpenAPIV3Schema: clusterv1.JSONSchemaProps{ |
| 41 | + Description: "Nutanix Prism Central endpoint configuration", |
| 42 | + Type: "object", |
| 43 | + Properties: map[string]clusterv1.JSONSchemaProps{ |
| 44 | + "host": { |
| 45 | + Description: "host ip/fqdn for Prism Central Server", |
| 46 | + Type: "string", |
| 47 | + }, |
| 48 | + "port": { |
| 49 | + Description: "port for Prism Central Server", |
| 50 | + Type: "integer", |
| 51 | + }, |
| 52 | + "insecure": { |
| 53 | + Description: "Prism Central Certificate checking", |
| 54 | + Type: "boolean", |
| 55 | + }, |
| 56 | + "additionalTrustBundle": { |
| 57 | + Description: "Name of configMap with certificate trust bundle used for Prism Central connection", |
| 58 | + Type: "string", |
| 59 | + }, |
| 60 | + "credentialSecret": { |
| 61 | + Description: "Name of a Credential information secret for the target Prism instance", |
| 62 | + Type: "string", |
| 63 | + }, |
| 64 | + }, |
| 65 | + }, |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +type NutanixControlPlaneEndpointSpec struct { |
| 70 | + Host string `json:"host,omitempty"` |
| 71 | + Port int32 `json:"port,omitempty"` |
| 72 | +} |
| 73 | + |
| 74 | +func (NutanixControlPlaneEndpointSpec) VariableSchema() clusterv1.VariableSchema { |
| 75 | + return clusterv1.VariableSchema{ |
| 76 | + OpenAPIV3Schema: clusterv1.JSONSchemaProps{ |
| 77 | + Description: "Nutanix control-plane endpoint configuration", |
| 78 | + Type: "object", |
| 79 | + Properties: map[string]clusterv1.JSONSchemaProps{ |
| 80 | + "host": { |
| 81 | + Description: "host ip/fqdn for control plane API Server", |
| 82 | + Type: "string", |
| 83 | + }, |
| 84 | + "port": { |
| 85 | + Description: "port for control plane API Server", |
| 86 | + Type: "integer", |
| 87 | + }, |
| 88 | + }, |
| 89 | + }, |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +type NutanixFailureDomains []NutanixFailureDomain |
| 94 | + |
| 95 | +func (NutanixFailureDomains) VariableSchema() clusterv1.VariableSchema { |
| 96 | + resourceSchema := NutanixFailureDomain{}.VariableSchema().OpenAPIV3Schema |
| 97 | + |
| 98 | + return clusterv1.VariableSchema{ |
| 99 | + OpenAPIV3Schema: clusterv1.JSONSchemaProps{ |
| 100 | + Description: "Nutanix failure domains", |
| 101 | + Type: "array", |
| 102 | + Items: &resourceSchema, |
| 103 | + }, |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +type NutanixFailureDomain struct { |
| 108 | + // name defines the unique name of a failure domain. |
| 109 | + // Name is required and must be at most 64 characters in length. |
| 110 | + // It must consist of only lower case alphanumeric characters and hyphens (-). |
| 111 | + // It must start and end with an alphanumeric character. |
| 112 | + // This value is arbitrary and is used to identify the failure domain within the platform. |
| 113 | + Name string `json:"name"` |
| 114 | + |
| 115 | + // cluster is to identify the cluster (the Prism Element under management of the Prism Central), |
| 116 | + // in which the Machine's VM will be created. The cluster identifier (uuid or name) can be obtained |
| 117 | + // from the Prism Central console or using the prism_central API. |
| 118 | + Cluster NutanixResourceIdentifier `json:"cluster"` |
| 119 | + |
| 120 | + // subnets holds a list of identifiers (one or more) of the cluster's network subnets |
| 121 | + // for the Machine's VM to connect to. The subnet identifiers (uuid or name) can be |
| 122 | + // obtained from the Prism Central console or using the prism_central API. |
| 123 | + Subnets []NutanixResourceIdentifier `json:"subnets"` |
| 124 | + |
| 125 | + // indicates if a failure domain is suited for control plane nodes |
| 126 | + ControlPlane bool `json:"controlPlane,omitempty"` |
| 127 | +} |
| 128 | + |
| 129 | +func (NutanixFailureDomain) VariableSchema() clusterv1.VariableSchema { |
| 130 | + return clusterv1.VariableSchema{ |
| 131 | + OpenAPIV3Schema: clusterv1.JSONSchemaProps{ |
| 132 | + Description: "Nutanix Failure Domain", |
| 133 | + Type: "object", |
| 134 | + Properties: map[string]clusterv1.JSONSchemaProps{ |
| 135 | + "name": { |
| 136 | + Description: "name of failure domain", |
| 137 | + Type: "string", |
| 138 | + }, |
| 139 | + "cluster": NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema, |
| 140 | + "subnets": NutanixResourceIdentifiers{}.VariableSchema().OpenAPIV3Schema, |
| 141 | + "controlPlane": { |
| 142 | + Description: "indicates if a failure domain is suited for control plane nodes", |
| 143 | + Type: "boolean", |
| 144 | + }, |
| 145 | + }, |
| 146 | + }, |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +type NutanixResourceIdentifiers []NutanixResourceIdentifier |
| 151 | + |
| 152 | +func (NutanixResourceIdentifiers) VariableSchema() clusterv1.VariableSchema { |
| 153 | + resourceSchema := NutanixResourceIdentifier{}.VariableSchema().OpenAPIV3Schema |
| 154 | + |
| 155 | + return clusterv1.VariableSchema{ |
| 156 | + OpenAPIV3Schema: clusterv1.JSONSchemaProps{ |
| 157 | + Description: "Nutanix resource identifier", |
| 158 | + Type: "array", |
| 159 | + Items: &resourceSchema, |
| 160 | + }, |
| 161 | + } |
| 162 | +} |
0 commit comments