Skip to content

Commit 94b7d85

Browse files
authored
fix: use external Nutanix API types directly (#698)
**What problem does this PR solve?**: From what I can tell there is no longer a need to have these separate types. These types get used by other projects where it generates a swagger spec. This change also fixes a swagger issue complaining about a circular reference since the types are named the same. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 7f32b05 commit 94b7d85

File tree

4 files changed

+23
-75
lines changed

4 files changed

+23
-75
lines changed

api/v1alpha1/nutanix_node_types.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ type NutanixMachineDetails struct {
2929
// image identifies the image uploaded to Prism Central (PC). The identifier
3030
// (uuid or name) can be obtained from the console or API.
3131
// +kubebuilder:validation:Required
32-
Image NutanixResourceIdentifier `json:"image"`
32+
Image capxv1.NutanixResourceIdentifier `json:"image"`
3333

3434
// cluster identifies the Prism Element in which the machine will be created.
3535
// The identifier (uuid or name) can be obtained from the console or API.
3636
// +kubebuilder:validation:Required
37-
Cluster NutanixResourceIdentifier `json:"cluster"`
37+
Cluster capxv1.NutanixResourceIdentifier `json:"cluster"`
3838

3939
// subnet identifies the network subnet to use for the machine.
4040
// The identifier (uuid or name) can be obtained from the console or API.
4141
// +kubebuilder:validation:Required
42-
Subnets []NutanixResourceIdentifier `json:"subnets"`
42+
Subnets []capxv1.NutanixResourceIdentifier `json:"subnets"`
4343

4444
// List of categories that need to be added to the machines. Categories must already
4545
// exist in Prism Central. One category key can have more than one value.
4646
// +kubebuilder:validation:Optional
47-
AdditionalCategories []NutanixCategoryIdentifier `json:"additionalCategories,omitempty"`
47+
AdditionalCategories []capxv1.NutanixCategoryIdentifier `json:"additionalCategories,omitempty"`
4848

4949
// Defines the boot type of the virtual machine. Only supports UEFI and Legacy
5050
// +kubebuilder:validation:Optional
5151
// +kubebuilder:validation:Enum:=legacy;uefi
52-
BootType NutanixBootType `json:"bootType"`
52+
BootType capxv1.NutanixBootType `json:"bootType"`
5353

5454
// systemDiskSize is size (in Quantity format) of the system disk of the VM
5555
// The minimum systemDiskSize is 20Gi bytes
@@ -59,19 +59,9 @@ type NutanixMachineDetails struct {
5959
// add the virtual machines to the project defined in Prism Central.
6060
// The project must already be present in the Prism Central.
6161
// +kubebuilder:validation:Optional
62-
Project *NutanixResourceIdentifier `json:"project,omitempty"`
62+
Project *capxv1.NutanixResourceIdentifier `json:"project,omitempty"`
6363

6464
// List of GPU devices that need to be added to the machines.
6565
// +kubebuilder:validation:Optional
6666
GPUs []capxv1.NutanixGPU `json:"gpus,omitempty"`
6767
}
68-
69-
// NutanixIdentifierType is an enumeration of different resource identifier types.
70-
type NutanixIdentifierType capxv1.NutanixIdentifierType
71-
72-
// NutanixBootType is an enumeration of different boot types.
73-
type NutanixBootType capxv1.NutanixBootType
74-
75-
type NutanixResourceIdentifier capxv1.NutanixResourceIdentifier
76-
77-
type NutanixCategoryIdentifier capxv1.NutanixCategoryIdentifier

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 4 additions & 46 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_control_plane_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ import (
2020

2121
var (
2222
variableWithAllFieldsSet = v1alpha1.NutanixMachineDetails{
23-
BootType: v1alpha1.NutanixBootType(capxv1.NutanixBootTypeLegacy),
23+
BootType: capxv1.NutanixBootTypeLegacy,
2424
VCPUSockets: 2,
2525
VCPUsPerSocket: 1,
26-
Image: v1alpha1.NutanixResourceIdentifier{
26+
Image: capxv1.NutanixResourceIdentifier{
2727
Type: capxv1.NutanixIdentifierName,
2828
Name: ptr.To("fake-image"),
2929
},
30-
Cluster: v1alpha1.NutanixResourceIdentifier{
30+
Cluster: capxv1.NutanixResourceIdentifier{
3131
Type: capxv1.NutanixIdentifierName,
3232
Name: ptr.To("fake-pe-cluster"),
3333
},
3434
MemorySize: resource.MustParse("8Gi"),
3535
SystemDiskSize: resource.MustParse("40Gi"),
36-
Subnets: []v1alpha1.NutanixResourceIdentifier{
36+
Subnets: []capxv1.NutanixResourceIdentifier{
3737
{
3838
Type: capxv1.NutanixIdentifierName,
3939
Name: ptr.To("fake-subnet"),
4040
},
4141
},
42-
AdditionalCategories: []v1alpha1.NutanixCategoryIdentifier{
42+
AdditionalCategories: []capxv1.NutanixCategoryIdentifier{
4343
{
4444
Key: "fake-key",
4545
Value: "fake-value",
@@ -49,7 +49,7 @@ var (
4949
Value: "fake-value2",
5050
},
5151
},
52-
Project: ptr.To(v1alpha1.NutanixResourceIdentifier{
52+
Project: ptr.To(capxv1.NutanixResourceIdentifier{
5353
Type: capxv1.NutanixIdentifierName,
5454
Name: ptr.To("fake-project"),
5555
}),

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestVariableValidation(t *testing.T) {
2020

2121
withAdditionalCategories := minimumClusterConfigSpec()
2222
//nolint:lll // gofumpt formats is this way
23-
withAdditionalCategories.ControlPlane.Nutanix.MachineDetails.AdditionalCategories = []v1alpha1.NutanixCategoryIdentifier{
23+
withAdditionalCategories.ControlPlane.Nutanix.MachineDetails.AdditionalCategories = []capxv1.NutanixCategoryIdentifier{
2424
{
2525
Key: "fake-key",
2626
Value: "fake-value1",
@@ -33,7 +33,7 @@ func TestVariableValidation(t *testing.T) {
3333

3434
withProject := minimumClusterConfigSpec()
3535
withProject.ControlPlane.Nutanix.MachineDetails.Project = ptr.To(
36-
v1alpha1.NutanixResourceIdentifier{
36+
capxv1.NutanixResourceIdentifier{
3737
Type: capxv1.NutanixIdentifierName,
3838
Name: ptr.To("fake-project"),
3939
},
@@ -50,7 +50,7 @@ func TestVariableValidation(t *testing.T) {
5050

5151
invalidProjectType := minimumClusterConfigSpec()
5252
invalidProjectType.ControlPlane.Nutanix.MachineDetails.Project = ptr.To(
53-
v1alpha1.NutanixResourceIdentifier{
53+
capxv1.NutanixResourceIdentifier{
5454
Type: "invalid-project-type",
5555
Name: ptr.To("fake-project"),
5656
},
@@ -102,20 +102,20 @@ func minimumClusterConfigSpec() v1alpha1.NutanixClusterConfigSpec {
102102
ControlPlane: &v1alpha1.NutanixNodeConfigSpec{
103103
Nutanix: &v1alpha1.NutanixNodeSpec{
104104
MachineDetails: v1alpha1.NutanixMachineDetails{
105-
BootType: v1alpha1.NutanixBootType(capxv1.NutanixBootTypeLegacy),
105+
BootType: capxv1.NutanixBootTypeLegacy,
106106
VCPUSockets: 2,
107107
VCPUsPerSocket: 1,
108-
Image: v1alpha1.NutanixResourceIdentifier{
108+
Image: capxv1.NutanixResourceIdentifier{
109109
Type: capxv1.NutanixIdentifierName,
110110
Name: ptr.To("fake-image"),
111111
},
112-
Cluster: v1alpha1.NutanixResourceIdentifier{
112+
Cluster: capxv1.NutanixResourceIdentifier{
113113
Type: capxv1.NutanixIdentifierName,
114114
Name: ptr.To("fake-pe-cluster"),
115115
},
116116
MemorySize: resource.MustParse("8Gi"),
117117
SystemDiskSize: resource.MustParse("40Gi"),
118-
Subnets: []v1alpha1.NutanixResourceIdentifier{},
118+
Subnets: []capxv1.NutanixResourceIdentifier{},
119119
},
120120
},
121121
},

0 commit comments

Comments
 (0)