Skip to content

Commit ce6453f

Browse files
committed
fix: use types directly
1 parent d5a279c commit ce6453f

File tree

6 files changed

+20
-64
lines changed

6 files changed

+20
-64
lines changed

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,18 @@ spec:
276276
items:
277277
properties:
278278
deviceID:
279-
description: DeviceID is the id of the GPU entity.
279+
description: deviceID is the id of the GPU entity.
280280
format: int64
281281
type: integer
282282
name:
283-
description: Name is the GPU name
283+
description: name is the GPU name
284284
type: string
285285
type:
286286
description: Type is the identifier type to use
287287
for this resource.
288+
enum:
289+
- deviceID
290+
- name
288291
type: string
289292
required:
290293
- type

api/v1alpha1/crds/caren.nutanix.com_nutanixnodeconfigs.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,18 @@ spec:
9494
items:
9595
properties:
9696
deviceID:
97-
description: DeviceID is the id of the GPU entity.
97+
description: deviceID is the id of the GPU entity.
9898
format: int64
9999
type: integer
100100
name:
101-
description: Name is the GPU name
101+
description: name is the GPU name
102102
type: string
103103
type:
104104
description: Type is the identifier type to use for
105105
this resource.
106+
enum:
107+
- deviceID
108+
- name
106109
type: string
107110
required:
108111
- type

api/v1alpha1/nutanix_node_types.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,7 @@ type NutanixMachineDetails struct {
6363

6464
// List of GPU devices that need to be added to the machines.
6565
// +kubebuilder:validation:Optional
66-
GPUs []NutanixGPU `json:"gpus,omitempty"`
67-
}
68-
69-
type NutanixGPU struct {
70-
// Type is the identifier type to use for this resource.
71-
// +kubebuilder:validation:Required
72-
Type NutanixGPUIdentifierType `json:"type"`
73-
74-
// DeviceID is the id of the GPU entity.
75-
// +kubebuilder:validation:Optional
76-
DeviceID *int64 `json:"deviceID,omitempty"`
77-
78-
// Name is the GPU name
79-
// +kubebuilder:validation:Optional
80-
Name *string `json:"name,omitempty"`
66+
GPUs []capxv1.NutanixGPU `json:"gpus,omitempty"`
8167
}
8268

8369
// NutanixIdentifierType is an enumeration of different resource identifier types.
@@ -89,5 +75,3 @@ type NutanixBootType capxv1.NutanixBootType
8975
type NutanixResourceIdentifier capxv1.NutanixResourceIdentifier
9076

9177
type NutanixCategoryIdentifier capxv1.NutanixCategoryIdentifier
92-
93-
type NutanixGPUIdentifierType capxv1.NutanixGPUIdentifierType

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,13 @@ func (h *nutanixMachineDetailsPatchHandler) Mutate(
122122
capxv1.NutanixResourceIdentifier(*nutanixMachineDetailsVar.Project),
123123
)
124124
}
125-
if nutanixMachineDetailsVar.GPUs != nil {
126-
spec.GPUs = make(
127-
[]capxv1.NutanixGPU,
128-
len(nutanixMachineDetailsVar.GPUs),
129-
)
125+
spec.GPUs = make(
126+
[]capxv1.NutanixGPU,
127+
len(nutanixMachineDetailsVar.GPUs),
128+
)
130129

131-
for i, gpu := range nutanixMachineDetailsVar.GPUs {
132-
gpuType := capxv1.NutanixGPUIdentifierType(gpu.Type)
133-
spec.GPUs[i] = capxv1.NutanixGPU{
134-
Type: gpuType,
135-
}
136-
if gpuType == capxv1.NutanixGPUIdentifierName {
137-
spec.GPUs[i].Name = gpu.Name
138-
continue
139-
}
140-
spec.GPUs[i].DeviceID = gpu.DeviceID
141-
}
130+
for i, gpu := range nutanixMachineDetailsVar.GPUs {
131+
spec.GPUs[i] = gpu
142132
}
143133

144134
obj.Spec.Template.Spec = spec

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var (
5555
Type: capxv1.NutanixIdentifierName,
5656
Name: ptr.To("fake-project"),
5757
}),
58-
GPUs: []v1alpha1.NutanixGPU{
58+
GPUs: []capxv1.NutanixGPU{
5959
{
6060
Type: "name",
6161
Name: ptr.To("gpu1"),

0 commit comments

Comments
 (0)