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

Commit abccd91

Browse files
committed
added enum in the api
1 parent 41c597b commit abccd91

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

api/v1alpha1/nutanix_node_types.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package v1alpha1
55

66
import (
7+
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/variables"
78
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
89
)
910

@@ -29,6 +30,10 @@ func (NutanixIdentifierType) VariableSchema() clusterv1.VariableSchema {
2930
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
3031
Type: "string",
3132
Description: "NutanixIdentifierType is an enumeration of different resource identifier types",
33+
Enum: variables.MustMarshalValuesToEnumJSON(
34+
NutanixIdentifierName,
35+
NutanixIdentifierUUID,
36+
),
3237
},
3338
}
3439
}
@@ -41,6 +46,10 @@ func (NutanixBootType) VariableSchema() clusterv1.VariableSchema {
4146
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
4247
Type: "string",
4348
Description: "NutanixBootType is an enumeration of different boot types.",
49+
Enum: variables.MustMarshalValuesToEnumJSON(
50+
NutanixBootTypeLegacy,
51+
NutanixBootTypeUEFI,
52+
),
4453
},
4554
}
4655
}
@@ -53,6 +62,9 @@ func (NutanixGPUIdentifierType) VariableSchema() clusterv1.VariableSchema {
5362
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
5463
Type: "string",
5564
Description: "NutanixGPUIdentifierType is an enumeration of different resource identifier types for GPU entities.",
65+
// TODO:deepakm-ntnx add GPU Identifier type enums
66+
// Enum: variables.MustMarshalValuesToEnumJSON(
67+
// ),
5668
},
5769
}
5870
}
@@ -169,7 +181,7 @@ func (NutanixResourceIdentifier) VariableSchema() clusterv1.VariableSchema {
169181
Description: "Nutanix Resource Identifier",
170182
Type: "object",
171183
Properties: map[string]clusterv1.JSONSchemaProps{
172-
"type": NutanixIdentifierType("name").VariableSchema().OpenAPIV3Schema,
184+
"type": NutanixIdentifierType("").VariableSchema().OpenAPIV3Schema,
173185
"uuid": {
174186
Type: "string",
175187
Description: "uuid is the UUID of the resource in the PC.",

pkg/handlers/nutanix/mutation/machinedetails/inject_control_plane.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ func (h *nutanixMachineDetailsControlPlanePatchHandler) Mutate(
139139
subnet := capxv1.NutanixResourceIdentifier{}
140140
if subnetCRE.Type == v1alpha1.NutanixIdentifierName {
141141
subnet.Type = capxv1.NutanixIdentifierName
142-
if subnetCRE.Name == nil {
142+
if subnetCRE.Name == nil || len(*subnetCRE.Name) == 0{
143143
continue
144144
}
145145
subnet.Name = subnetCRE.Name
146146
} else {
147147
subnet.Type = capxv1.NutanixIdentifierUUID
148-
if subnetCRE.UUID == nil {
148+
if subnetCRE.UUID == nil || len(*subnetCRE.UUID) == 0{
149149
continue
150150
}
151151
subnet.UUID = subnetCRE.UUID

pkg/handlers/nutanix/mutation/machinedetails/inject_worker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ func (h *nutanixMachineDetailsWorkerPatchHandler) Mutate(
128128
subnet := capxv1.NutanixResourceIdentifier{}
129129
if subnetCRE.Type == v1alpha1.NutanixIdentifierName {
130130
subnet.Type = capxv1.NutanixIdentifierName
131-
if subnetCRE.Name == nil {
131+
if subnetCRE.Name == nil || len(*subnetCRE.Name) == 0 {
132132
continue
133133
}
134134
subnet.Name = subnetCRE.Name
135135
} else {
136136
subnet.Type = capxv1.NutanixIdentifierUUID
137-
if subnetCRE.UUID == nil {
137+
if subnetCRE.UUID == nil || len(*subnetCRE.UUID) == 0 {
138138
continue
139139
}
140140
subnet.UUID = subnetCRE.UUID

0 commit comments

Comments
 (0)