Skip to content

Commit cf277f9

Browse files
fix: fixes suggested from failing make pre-commit run
1 parent 8af088f commit cf277f9

File tree

7 files changed

+48
-18
lines changed

7 files changed

+48
-18
lines changed

api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1/conditions.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,7 @@ const (
7474
// CredentialRefSecretOwnerSetCondition shows the status of setting the Owner
7575
CredentialRefSecretOwnerSetCondition capiv1.ConditionType = "CredentialRefSecretOwnerSet"
7676

77-
CredentialRefSecretOwnerSetFailed = "CredentialRefSecretOwnerSetFailed"
77+
CredentialRefSecretOwnerSetFailed = "CredentialRefSecretOwnerSetFailed"
78+
TrustBundleSecretOwnerSetCondition = "TrustBundleSecretOwnerSet"
79+
TrustBundleSecretOwnerSetFailed = "TrustBundleSecretOwnerSetFailed"
7880
)

api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1/nutanixcluster_types.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"cmp"
2021
"fmt"
2122

2223
credentialTypes "github.com/nutanix-cloud-native/prism-go-client/environment/credentials"
24+
corev1 "k8s.io/api/core/v1"
2325
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2426
capiv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2527
"sigs.k8s.io/cluster-api/errors"
@@ -128,8 +130,6 @@ type NutanixFailureDomain struct {
128130
// obtained from the Prism Central console or using the prism_central API.
129131
// +kubebuilder:validation:Required
130132
// +kubebuilder:validation:MinItems=1
131-
// +listType=map
132-
// +listMapKey=type
133133
Subnets []NutanixResourceIdentifier `json:"subnets"`
134134

135135
// indicates if a failure domain is suited for control plane nodes
@@ -162,6 +162,24 @@ func (ncl *NutanixCluster) GetPrismCentralCredentialRef() (*credentialTypes.Nuta
162162
return prismCentralInfo.CredentialRef, nil
163163
}
164164

165+
// GetPrismCentralTrustBundle returns the trust bundle reference for the Nutanix Prism Central.
166+
func (ncl *NutanixCluster) GetPrismCentralTrustBundle() *credentialTypes.NutanixTrustBundleReference {
167+
prismCentralInfo := ncl.Spec.PrismCentral
168+
if prismCentralInfo == nil ||
169+
prismCentralInfo.AdditionalTrustBundle == nil ||
170+
prismCentralInfo.AdditionalTrustBundle.Kind == credentialTypes.NutanixTrustBundleKindString {
171+
return nil
172+
}
173+
174+
return prismCentralInfo.AdditionalTrustBundle
175+
}
176+
177+
// GetNamespacedName returns the namespaced name of the NutanixCluster.
178+
func (ncl *NutanixCluster) GetNamespacedName() string {
179+
namespace := cmp.Or(ncl.Namespace, corev1.NamespaceDefault)
180+
return fmt.Sprintf("%s/%s", namespace, ncl.Name)
181+
}
182+
165183
// +kubebuilder:object:root=true
166184

167185
// NutanixClusterList contains a list of NutanixCluster

api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1/nutanixmachine_types.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,26 @@ const (
3535
// resources associated with NutanixMachine before removing it from the
3636
// API Server.
3737
NutanixMachineFinalizer = "nutanixmachine.infrastructure.cluster.x-k8s.io"
38+
39+
// NutanixMachineBootstrapRefKindSecret represents the Kind of Secret
40+
// referenced by NutanixMachine's BootstrapRef.
41+
NutanixMachineBootstrapRefKindSecret = "Secret"
42+
43+
// NutanixMachineBootstrapRefKindImage represents the Kind of Image
44+
// referenced by NutanixMachine's BootstrapRef. If the BootstrapRef.Kind is set
45+
// to Image, the NutanixMachine will be created with the image mounted
46+
// as a CD-ROM.
47+
NutanixMachineBootstrapRefKindImage = "Image"
3848
)
3949

4050
// NutanixMachineSpec defines the desired state of NutanixMachine
4151
type NutanixMachineSpec struct {
4252
// SPEC FIELDS - desired state of NutanixMachine
4353
// Important: Run "make" to regenerate code after modifying this file
4454

45-
ProviderID string `json:"providerID"`
55+
// ProviderID is the unique identifier as specified by the cloud provider.
56+
// +optional
57+
ProviderID string `json:"providerID,omitempty"`
4658
// vcpusPerSocket is the number of vCPUs per socket of the VM
4759
// +kubebuilder:validation:Required
4860
// +kubebuilder:validation:Minimum=1

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/cluster-api-runtime-extensions-nutanix/defaultclusterclasses/nutanix-cluster-class.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ spec:
196196
name: ""
197197
type: name
198198
memorySize: 4Gi
199-
providerID: nutanix://vm-uuid
200199
subnet:
201200
- name: ""
202201
type: name
@@ -221,7 +220,6 @@ spec:
221220
name: ""
222221
type: name
223222
memorySize: 4Gi
224-
providerID: nutanix://vm-uuid
225223
subnet:
226224
- name: ""
227225
type: name

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ func (h *nutanixMachineDetailsPatchHandler) Mutate(
9292

9393
spec := obj.Spec.Template.Spec
9494

95-
spec.BootType = capxv1.NutanixBootType(nutanixMachineDetailsVar.BootType)
96-
spec.Cluster = capxv1.NutanixResourceIdentifier(nutanixMachineDetailsVar.Cluster)
97-
spec.Image = capxv1.NutanixResourceIdentifier(nutanixMachineDetailsVar.Image)
95+
spec.BootType = nutanixMachineDetailsVar.BootType
96+
spec.Cluster = nutanixMachineDetailsVar.Cluster
97+
spec.Image = nutanixMachineDetailsVar.Image
9898

9999
spec.VCPUSockets = nutanixMachineDetailsVar.VCPUSockets
100100
spec.VCPUsPerSocket = nutanixMachineDetailsVar.VCPUsPerSocket
@@ -105,21 +105,19 @@ func (h *nutanixMachineDetailsPatchHandler) Mutate(
105105
[]capxv1.NutanixResourceIdentifier,
106106
len(nutanixMachineDetailsVar.Subnets),
107107
)
108-
for i, subnet := range nutanixMachineDetailsVar.Subnets {
109-
spec.Subnets[i] = capxv1.NutanixResourceIdentifier(subnet)
110-
}
108+
109+
copy(spec.Subnets, nutanixMachineDetailsVar.Subnets)
111110

112111
spec.AdditionalCategories = make(
113112
[]capxv1.NutanixCategoryIdentifier,
114113
len(nutanixMachineDetailsVar.AdditionalCategories),
115114
)
116-
for i, category := range nutanixMachineDetailsVar.AdditionalCategories {
117-
spec.AdditionalCategories[i] = capxv1.NutanixCategoryIdentifier(category)
118-
}
115+
116+
copy(spec.AdditionalCategories, nutanixMachineDetailsVar.AdditionalCategories)
119117

120118
if nutanixMachineDetailsVar.Project != nil {
121119
spec.Project = ptr.To(
122-
capxv1.NutanixResourceIdentifier(*nutanixMachineDetailsVar.Project),
120+
*nutanixMachineDetailsVar.Project,
123121
)
124122
}
125123
spec.GPUs = make(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestVariableValidation(t *testing.T) {
1919
requiredFields := minimumClusterConfigSpec()
2020

2121
withAdditionalCategories := minimumClusterConfigSpec()
22-
//nolint:lll // gofumpt formats is this way
22+
2323
withAdditionalCategories.ControlPlane.Nutanix.MachineDetails.AdditionalCategories = []capxv1.NutanixCategoryIdentifier{
2424
{
2525
Key: "fake-key",

0 commit comments

Comments
 (0)