Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use external Nutanix API types directly #698

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions api/v1alpha1/nutanix_node_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ type NutanixMachineDetails struct {
// image identifies the image uploaded to Prism Central (PC). The identifier
// (uuid or name) can be obtained from the console or API.
// +kubebuilder:validation:Required
Image NutanixResourceIdentifier `json:"image"`
Image capxv1.NutanixResourceIdentifier `json:"image"`

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

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

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

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

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

// List of GPU devices that need to be added to the machines.
// +kubebuilder:validation:Optional
GPUs []capxv1.NutanixGPU `json:"gpus,omitempty"`
}

// NutanixIdentifierType is an enumeration of different resource identifier types.
type NutanixIdentifierType capxv1.NutanixIdentifierType

// NutanixBootType is an enumeration of different boot types.
type NutanixBootType capxv1.NutanixBootType

type NutanixResourceIdentifier capxv1.NutanixResourceIdentifier

type NutanixCategoryIdentifier capxv1.NutanixCategoryIdentifier
50 changes: 4 additions & 46 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ import (

var (
variableWithAllFieldsSet = v1alpha1.NutanixMachineDetails{
BootType: v1alpha1.NutanixBootType(capxv1.NutanixBootTypeLegacy),
BootType: capxv1.NutanixBootTypeLegacy,
VCPUSockets: 2,
VCPUsPerSocket: 1,
Image: v1alpha1.NutanixResourceIdentifier{
Image: capxv1.NutanixResourceIdentifier{
Type: capxv1.NutanixIdentifierName,
Name: ptr.To("fake-image"),
},
Cluster: v1alpha1.NutanixResourceIdentifier{
Cluster: capxv1.NutanixResourceIdentifier{
Type: capxv1.NutanixIdentifierName,
Name: ptr.To("fake-pe-cluster"),
},
MemorySize: resource.MustParse("8Gi"),
SystemDiskSize: resource.MustParse("40Gi"),
Subnets: []v1alpha1.NutanixResourceIdentifier{
Subnets: []capxv1.NutanixResourceIdentifier{
{
Type: capxv1.NutanixIdentifierName,
Name: ptr.To("fake-subnet"),
},
},
AdditionalCategories: []v1alpha1.NutanixCategoryIdentifier{
AdditionalCategories: []capxv1.NutanixCategoryIdentifier{
{
Key: "fake-key",
Value: "fake-value",
Expand All @@ -49,7 +49,7 @@ var (
Value: "fake-value2",
},
},
Project: ptr.To(v1alpha1.NutanixResourceIdentifier{
Project: ptr.To(capxv1.NutanixResourceIdentifier{
Type: capxv1.NutanixIdentifierName,
Name: ptr.To("fake-project"),
}),
Expand Down
14 changes: 7 additions & 7 deletions pkg/handlers/nutanix/mutation/machinedetails/variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestVariableValidation(t *testing.T) {

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

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

invalidProjectType := minimumClusterConfigSpec()
invalidProjectType.ControlPlane.Nutanix.MachineDetails.Project = ptr.To(
v1alpha1.NutanixResourceIdentifier{
capxv1.NutanixResourceIdentifier{
Type: "invalid-project-type",
Name: ptr.To("fake-project"),
},
Expand Down Expand Up @@ -102,20 +102,20 @@ func minimumClusterConfigSpec() v1alpha1.NutanixClusterConfigSpec {
ControlPlane: &v1alpha1.NutanixNodeConfigSpec{
Nutanix: &v1alpha1.NutanixNodeSpec{
MachineDetails: v1alpha1.NutanixMachineDetails{
BootType: v1alpha1.NutanixBootType(capxv1.NutanixBootTypeLegacy),
BootType: capxv1.NutanixBootTypeLegacy,
VCPUSockets: 2,
VCPUsPerSocket: 1,
Image: v1alpha1.NutanixResourceIdentifier{
Image: capxv1.NutanixResourceIdentifier{
Type: capxv1.NutanixIdentifierName,
Name: ptr.To("fake-image"),
},
Cluster: v1alpha1.NutanixResourceIdentifier{
Cluster: capxv1.NutanixResourceIdentifier{
Type: capxv1.NutanixIdentifierName,
Name: ptr.To("fake-pe-cluster"),
},
MemorySize: resource.MustParse("8Gi"),
SystemDiskSize: resource.MustParse("40Gi"),
Subnets: []v1alpha1.NutanixResourceIdentifier{},
Subnets: []capxv1.NutanixResourceIdentifier{},
},
},
},
Expand Down
Loading