@@ -6,10 +6,6 @@ package v1alpha1
6
6
import (
7
7
corev1 "k8s.io/api/core/v1"
8
8
storagev1 "k8s.io/api/storage/v1"
9
- "k8s.io/utils/ptr"
10
- clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
11
-
12
- "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables"
13
9
)
14
10
15
11
const (
@@ -40,22 +36,6 @@ type Addons struct {
40
36
CSIProviders * CSI `json:"csi,omitempty"`
41
37
}
42
38
43
- func (Addons ) VariableSchema () clusterv1.VariableSchema {
44
- return clusterv1.VariableSchema {
45
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
46
- Description : "Cluster configuration" ,
47
- Type : "object" ,
48
- Properties : map [string ]clusterv1.JSONSchemaProps {
49
- "cni" : CNI {}.VariableSchema ().OpenAPIV3Schema ,
50
- "nfd" : NFD {}.VariableSchema ().OpenAPIV3Schema ,
51
- "clusterAutoscaler" : ClusterAutoscaler {}.VariableSchema ().OpenAPIV3Schema ,
52
- "csi" : CSI {}.VariableSchema ().OpenAPIV3Schema ,
53
- "ccm" : CCM {}.VariableSchema ().OpenAPIV3Schema ,
54
- },
55
- },
56
- }
57
- }
58
-
59
39
type AddonStrategy string
60
40
61
41
// CNI required for providing CNI configuration.
@@ -66,83 +46,18 @@ type CNI struct {
66
46
Strategy AddonStrategy `json:"strategy,omitempty"`
67
47
}
68
48
69
- func (CNI ) VariableSchema () clusterv1.VariableSchema {
70
- supportedCNIProviders := []string {CNIProviderCalico , CNIProviderCilium }
71
-
72
- return clusterv1.VariableSchema {
73
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
74
- Type : "object" ,
75
- Properties : map [string ]clusterv1.JSONSchemaProps {
76
- "provider" : {
77
- Description : "CNI provider to deploy" ,
78
- Type : "string" ,
79
- Enum : variables .MustMarshalValuesToEnumJSON (supportedCNIProviders ... ),
80
- },
81
- "strategy" : {
82
- Description : "Addon strategy used to deploy the CNI provider to the workload cluster" ,
83
- Type : "string" ,
84
- Enum : variables .MustMarshalValuesToEnumJSON (
85
- AddonStrategyClusterResourceSet ,
86
- AddonStrategyHelmAddon ,
87
- ),
88
- },
89
- },
90
- Required : []string {"provider" , "strategy" },
91
- },
92
- }
93
- }
94
-
95
49
// NFD tells us to enable or disable the node feature discovery addon.
96
50
type NFD struct {
97
51
// +optional
98
52
Strategy AddonStrategy `json:"strategy,omitempty"`
99
53
}
100
54
101
- func (NFD ) VariableSchema () clusterv1.VariableSchema {
102
- return clusterv1.VariableSchema {
103
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
104
- Type : "object" ,
105
- Properties : map [string ]clusterv1.JSONSchemaProps {
106
- "strategy" : {
107
- Description : "Addon strategy used to deploy Node Feature Discovery (NFD) to the workload cluster" ,
108
- Type : "string" ,
109
- Enum : variables .MustMarshalValuesToEnumJSON (
110
- AddonStrategyClusterResourceSet ,
111
- AddonStrategyHelmAddon ,
112
- ),
113
- },
114
- },
115
- Required : []string {"strategy" },
116
- },
117
- }
118
- }
119
-
120
55
// ClusterAutoscaler tells us to enable or disable the cluster-autoscaler addon.
121
56
type ClusterAutoscaler struct {
122
57
// +optional
123
58
Strategy AddonStrategy `json:"strategy,omitempty"`
124
59
}
125
60
126
- func (ClusterAutoscaler ) VariableSchema () clusterv1.VariableSchema {
127
- return clusterv1.VariableSchema {
128
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
129
- Type : "object" ,
130
- Properties : map [string ]clusterv1.JSONSchemaProps {
131
- "strategy" : {
132
- Description : "Addon strategy used to deploy cluster-autoscaler to the management cluster," +
133
- "targeting the workload cluster." ,
134
- Type : "string" ,
135
- Enum : variables .MustMarshalValuesToEnumJSON (
136
- AddonStrategyClusterResourceSet ,
137
- AddonStrategyHelmAddon ,
138
- ),
139
- },
140
- },
141
- Required : []string {"strategy" },
142
- },
143
- }
144
- }
145
-
146
61
type DefaultStorage struct {
147
62
ProviderName string `json:"providerName"`
148
63
StorageClassConfigName string `json:"storageClassConfigName"`
@@ -183,159 +98,9 @@ type StorageClassConfig struct {
183
98
AllowExpansion bool `json:"allowExpansion,omitempty"`
184
99
}
185
100
186
- func (StorageClassConfig ) VariableSchema () clusterv1.VariableSchema {
187
- supportedReclaimPolicies := []string {
188
- string (VolumeReclaimRecycle ),
189
- string (VolumeReclaimDelete ),
190
- string (VolumeReclaimRetain ),
191
- }
192
- supportedBindingModes := []string {
193
- string (VolumeBindingImmediate ),
194
- string (VolumeBindingWaitForFirstConsumer ),
195
- }
196
- return clusterv1.VariableSchema {
197
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
198
- Type : "object" ,
199
- Required : []string {"name" },
200
- Properties : map [string ]clusterv1.JSONSchemaProps {
201
- "name" : {
202
- Type : "string" ,
203
- Description : "Name of storage class config." ,
204
- },
205
- "parameters" : {
206
- Type : "object" ,
207
- Description : "Parameters passed into the storage class object." ,
208
- AdditionalProperties : & clusterv1.JSONSchemaProps {
209
- Type : "string" ,
210
- },
211
- },
212
- "reclaimPolicy" : {
213
- Type : "string" ,
214
- Enum : variables .MustMarshalValuesToEnumJSON (supportedReclaimPolicies ... ),
215
- Default : variables .MustMarshal (VolumeReclaimDelete ),
216
- },
217
- "volumeBindingMode" : {
218
- Type : "string" ,
219
- Enum : variables .MustMarshalValuesToEnumJSON (supportedBindingModes ... ),
220
- Default : variables .MustMarshal (VolumeBindingWaitForFirstConsumer ),
221
- },
222
- "allowExpansion" : {
223
- Type : "boolean" ,
224
- Default : variables .MustMarshal (false ),
225
- Description : "If the storage class should allow volume expanding" ,
226
- },
227
- },
228
- },
229
- }
230
- }
231
-
232
- func (CSIProvider ) VariableSchema () clusterv1.VariableSchema {
233
- supportedCSIProviders := []string {CSIProviderAWSEBS , CSIProviderNutanix }
234
- return clusterv1.VariableSchema {
235
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
236
- Type : "object" ,
237
- Required : []string {"name" , "strategy" },
238
- Properties : map [string ]clusterv1.JSONSchemaProps {
239
- "name" : {
240
- Description : "Name of the CSI Provider" ,
241
- Type : "string" ,
242
- Enum : variables .MustMarshalValuesToEnumJSON (
243
- supportedCSIProviders ... ),
244
- },
245
- "strategy" : {
246
- Description : "Addon strategy used to deploy the CSI provider to the workload cluster" ,
247
- Type : "string" ,
248
- Enum : variables .MustMarshalValuesToEnumJSON (
249
- AddonStrategyClusterResourceSet ,
250
- AddonStrategyHelmAddon ,
251
- ),
252
- },
253
- "credentials" : {
254
- Type : "object" ,
255
- Description : "The reference to any secret used by the CSI Provider." ,
256
- Properties : map [string ]clusterv1.JSONSchemaProps {
257
- "name" : {
258
- Type : "string" ,
259
- },
260
- },
261
- },
262
- "storageClassConfig" : {
263
- Type : "array" ,
264
- Items : ptr .To (StorageClassConfig {}.VariableSchema ().OpenAPIV3Schema ),
265
- },
266
- },
267
- },
268
- }
269
- }
270
-
271
- func (DefaultStorage ) VariableSchema () clusterv1.VariableSchema {
272
- supportedCSIProviders := []string {CSIProviderAWSEBS , CSIProviderNutanix }
273
- return clusterv1.VariableSchema {
274
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
275
- Type : "object" ,
276
- Description : "A tuple of provider name and storage class " ,
277
- Required : []string {"providerName" , "storageClassConfigName" },
278
- Properties : map [string ]clusterv1.JSONSchemaProps {
279
- "providerName" : {
280
- Type : "string" ,
281
- Description : "Name of the CSI Provider for the default storage class" ,
282
- Enum : variables .MustMarshalValuesToEnumJSON (
283
- supportedCSIProviders ... ,
284
- ),
285
- },
286
- "storageClassConfigName" : {
287
- Type : "string" ,
288
- Description : "Name of storage class config in any of the provider objects" ,
289
- },
290
- },
291
- },
292
- }
293
- }
294
-
295
- func (CSI ) VariableSchema () clusterv1.VariableSchema {
296
- return clusterv1.VariableSchema {
297
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
298
- Type : "object" ,
299
- Properties : map [string ]clusterv1.JSONSchemaProps {
300
- "providers" : {
301
- Type : "array" ,
302
- Items : ptr .To (CSIProvider {}.VariableSchema ().OpenAPIV3Schema ),
303
- },
304
- "defaultStorage" : DefaultStorage {}.VariableSchema ().OpenAPIV3Schema ,
305
- },
306
- },
307
- }
308
- }
309
-
310
101
// CCM tells us to enable or disable the cloud provider interface.
311
102
type CCM struct {
312
103
// A reference to the Secret for credential information for the target Prism Central instance
313
104
// +optional
314
105
Credentials * corev1.LocalObjectReference `json:"credentials,omitempty"`
315
106
}
316
-
317
- func (CCM ) VariableSchema () clusterv1.VariableSchema {
318
- // TODO Validate credentials is set.
319
- // This CCM is shared across all providers.
320
- // Some of these providers may require credentials to be set, but we don't want to require it for all providers.
321
- // The Nutanix CCM handler will fail in at runtime if credentials are not set.
322
- return clusterv1.VariableSchema {
323
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
324
- Type : "object" ,
325
- Properties : map [string ]clusterv1.JSONSchemaProps {
326
- "credentials" : {
327
- Description : "A reference to the Secret for credential information" +
328
- "for the target Prism Central instance" ,
329
- Type : "object" ,
330
- Properties : map [string ]clusterv1.JSONSchemaProps {
331
- "name" : {
332
- Description : "The name of the Secret" ,
333
- Type : "string" ,
334
- },
335
- },
336
- Required : []string {"name" },
337
- },
338
- },
339
- },
340
- }
341
- }
0 commit comments