From 3d07c434b5ac17336b56b64aebdbaddddf4bf901 Mon Sep 17 00:00:00 2001 From: Sid Shukla Date: Tue, 3 Dec 2024 16:42:54 +0100 Subject: [PATCH 1/2] fix(build): stop pegging a golanci-lint version in CI --- .github/workflows/build-dev.yaml | 2 -- devbox.lock | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-dev.yaml b/.github/workflows/build-dev.yaml index 890836481b..da7275d794 100644 --- a/.github/workflows/build-dev.yaml +++ b/.github/workflows/build-dev.yaml @@ -39,8 +39,6 @@ jobs: - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 - with: - version: v1.59 - name: Lint run: devbox run -- make lint-yaml diff --git a/devbox.lock b/devbox.lock index 87bbd8cb41..6022ba5622 100644 --- a/devbox.lock +++ b/devbox.lock @@ -426,50 +426,50 @@ } }, "golangci-lint@latest": { - "last_modified": "2024-07-20T09:11:00Z", - "resolved": "github:NixOS/nixpkgs/6e14bbce7bea6c4efd7adfa88a40dac750d80100#golangci-lint", + "last_modified": "2024-11-28T07:51:56Z", + "resolved": "github:NixOS/nixpkgs/226216574ada4c3ecefcbbec41f39ce4655f78ef#golangci-lint", "source": "devbox-search", - "version": "1.59.1", + "version": "1.62.2", "systems": { "aarch64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/80cn62vqs99adkpvjv5qmv9nvkahcy0s-golangci-lint-1.59.1", + "path": "/nix/store/yp07jnqgrbnvdibqz1m2i1fgj30vhd2b-golangci-lint-1.62.2", "default": true } ], - "store_path": "/nix/store/80cn62vqs99adkpvjv5qmv9nvkahcy0s-golangci-lint-1.59.1" + "store_path": "/nix/store/yp07jnqgrbnvdibqz1m2i1fgj30vhd2b-golangci-lint-1.62.2" }, "aarch64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/f91hm1xlmjy5y18lavfn9889azxam4mp-golangci-lint-1.59.1", + "path": "/nix/store/77qnd3ix2nrb8f5vppnv1pfd35h4vz04-golangci-lint-1.62.2", "default": true } ], - "store_path": "/nix/store/f91hm1xlmjy5y18lavfn9889azxam4mp-golangci-lint-1.59.1" + "store_path": "/nix/store/77qnd3ix2nrb8f5vppnv1pfd35h4vz04-golangci-lint-1.62.2" }, "x86_64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/pn0lpm53xffqvdfd72n4mfn8ja4kmf1h-golangci-lint-1.59.1", + "path": "/nix/store/ri36lilgaf8d4z2r96xfsk33162zrvwy-golangci-lint-1.62.2", "default": true } ], - "store_path": "/nix/store/pn0lpm53xffqvdfd72n4mfn8ja4kmf1h-golangci-lint-1.59.1" + "store_path": "/nix/store/ri36lilgaf8d4z2r96xfsk33162zrvwy-golangci-lint-1.62.2" }, "x86_64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/fx4p42sdx70hzpzsl71r5zwh8az0p74a-golangci-lint-1.59.1", + "path": "/nix/store/gr55w2x6wrzdvhhbzm4wc28cs4k7g7vr-golangci-lint-1.62.2", "default": true } ], - "store_path": "/nix/store/fx4p42sdx70hzpzsl71r5zwh8az0p74a-golangci-lint-1.59.1" + "store_path": "/nix/store/gr55w2x6wrzdvhhbzm4wc28cs4k7g7vr-golangci-lint-1.62.2" } } }, From 70be4d35291ae9a4e552224885a6afaa5a6b5114 Mon Sep 17 00:00:00 2001 From: Sid Shukla Date: Tue, 3 Dec 2024 17:23:44 +0100 Subject: [PATCH 2/2] fix(lint): Add govet nolint statements to fix golint action --- controllers/helpers.go | 8 ++++---- controllers/nutanixcluster_controller.go | 10 +++++----- controllers/nutanixmachine_controller.go | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/controllers/helpers.go b/controllers/helpers.go index f404792692..e814ad7d8c 100644 --- a/controllers/helpers.go +++ b/controllers/helpers.go @@ -766,7 +766,7 @@ func getPrismCentralClientForCluster(ctx context.Context, cluster *infrav1.Nutan managementEndpoint, err := clientHelper.BuildManagementEndpoint(ctx, cluster) if err != nil { log.Error(err, fmt.Sprintf("error occurred while getting management endpoint for cluster %q", cluster.GetNamespacedName())) - conditions.MarkFalse(cluster, infrav1.PrismCentralClientCondition, infrav1.PrismCentralClientInitializationFailed, capiv1.ConditionSeverityError, err.Error()) + conditions.MarkFalse(cluster, infrav1.PrismCentralClientCondition, infrav1.PrismCentralClientInitializationFailed, capiv1.ConditionSeverityError, err.Error()) //nolint:govet // error will not be a constant return nil, err } @@ -776,7 +776,7 @@ func getPrismCentralClientForCluster(ctx context.Context, cluster *infrav1.Nutan }) if err != nil { log.Error(err, "error occurred while getting nutanix prism v3 Client from cache") - conditions.MarkFalse(cluster, infrav1.PrismCentralClientCondition, infrav1.PrismCentralClientInitializationFailed, capiv1.ConditionSeverityError, err.Error()) + conditions.MarkFalse(cluster, infrav1.PrismCentralClientCondition, infrav1.PrismCentralClientInitializationFailed, capiv1.ConditionSeverityError, err.Error()) //nolint:govet // error will not be a constant return nil, fmt.Errorf("nutanix prism v3 Client error: %w", err) } @@ -791,7 +791,7 @@ func getPrismCentralV4ClientForCluster(ctx context.Context, cluster *infrav1.Nut managementEndpoint, err := clientHelper.BuildManagementEndpoint(ctx, cluster) if err != nil { log.Error(err, fmt.Sprintf("error occurred while getting management endpoint for cluster %q", cluster.GetNamespacedName())) - conditions.MarkFalse(cluster, infrav1.PrismCentralV4ClientCondition, infrav1.PrismCentralV4ClientInitializationFailed, capiv1.ConditionSeverityError, err.Error()) + conditions.MarkFalse(cluster, infrav1.PrismCentralV4ClientCondition, infrav1.PrismCentralV4ClientInitializationFailed, capiv1.ConditionSeverityError, err.Error()) //nolint:govet // error will not be a constant return nil, err } @@ -801,7 +801,7 @@ func getPrismCentralV4ClientForCluster(ctx context.Context, cluster *infrav1.Nut }) if err != nil { log.Error(err, "error occurred while getting nutanix prism v4 client from cache") - conditions.MarkFalse(cluster, infrav1.PrismCentralV4ClientCondition, infrav1.PrismCentralV4ClientInitializationFailed, capiv1.ConditionSeverityError, err.Error()) + conditions.MarkFalse(cluster, infrav1.PrismCentralV4ClientCondition, infrav1.PrismCentralV4ClientInitializationFailed, capiv1.ConditionSeverityError, err.Error()) //nolint:govet // error will not be a constant return nil, fmt.Errorf("nutanix prism v4 client error: %w", err) } diff --git a/controllers/nutanixcluster_controller.go b/controllers/nutanixcluster_controller.go index 65ff96528e..e381b23b6d 100644 --- a/controllers/nutanixcluster_controller.go +++ b/controllers/nutanixcluster_controller.go @@ -170,7 +170,7 @@ func (r *NutanixClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reque if err := r.reconcileCredentialRef(ctx, cluster); err != nil { log.Error(err, fmt.Sprintf("error occurred while reconciling credential ref for cluster %s", capiCluster.Name)) - conditions.MarkFalse(cluster, infrav1.CredentialRefSecretOwnerSetCondition, infrav1.CredentialRefSecretOwnerSetFailed, capiv1.ConditionSeverityError, err.Error()) + conditions.MarkFalse(cluster, infrav1.CredentialRefSecretOwnerSetCondition, infrav1.CredentialRefSecretOwnerSetFailed, capiv1.ConditionSeverityError, err.Error()) //nolint:govet // error will not be a constant return reconcile.Result{}, err } conditions.MarkTrue(cluster, infrav1.CredentialRefSecretOwnerSetCondition) @@ -312,7 +312,7 @@ func (r *NutanixClusterReconciler) reconcileCategories(rctx *nctx.ClusterContext defaultCategories := GetDefaultCAPICategoryIdentifiers(rctx.Cluster.Name) _, err := GetOrCreateCategories(rctx.Context, rctx.NutanixClient, defaultCategories) if err != nil { - conditions.MarkFalse(rctx.NutanixCluster, infrav1.ClusterCategoryCreatedCondition, infrav1.ClusterCategoryCreationFailed, capiv1.ConditionSeverityError, err.Error()) + conditions.MarkFalse(rctx.NutanixCluster, infrav1.ClusterCategoryCreatedCondition, infrav1.ClusterCategoryCreationFailed, capiv1.ConditionSeverityError, err.Error()) //nolint:govet // error will not be a constant return err } conditions.MarkTrue(rctx.NutanixCluster, infrav1.ClusterCategoryCreatedCondition) @@ -328,7 +328,7 @@ func (r *NutanixClusterReconciler) reconcileCategoriesDelete(rctx *nctx.ClusterC obsoleteCategories := GetObsoleteDefaultCAPICategoryIdentifiers(rctx.Cluster.Name) err := DeleteCategories(rctx.Context, rctx.NutanixClient, defaultCategories, obsoleteCategories) if err != nil { - conditions.MarkFalse(rctx.NutanixCluster, infrav1.ClusterCategoryCreatedCondition, infrav1.DeletionFailed, capiv1.ConditionSeverityWarning, err.Error()) + conditions.MarkFalse(rctx.NutanixCluster, infrav1.ClusterCategoryCreatedCondition, infrav1.DeletionFailed, capiv1.ConditionSeverityWarning, err.Error()) //nolint:govet // error will not be a constant return err } } else { @@ -395,7 +395,7 @@ func (r *NutanixClusterReconciler) reconcileTrustBundleRef(ctx context.Context, } if err := r.Client.Get(ctx, configMapKey, configMap); err != nil { log.Error(err, "error occurred while fetching trust bundle configmap", "nutanixCluster", nutanixCluster.Name) - conditions.MarkFalse(nutanixCluster, infrav1.TrustBundleSecretOwnerSetCondition, infrav1.TrustBundleSecretOwnerSetFailed, capiv1.ConditionSeverityError, err.Error()) + conditions.MarkFalse(nutanixCluster, infrav1.TrustBundleSecretOwnerSetCondition, infrav1.TrustBundleSecretOwnerSetFailed, capiv1.ConditionSeverityError, err.Error()) //nolint:govet // error will not be a constant return err } @@ -419,7 +419,7 @@ func (r *NutanixClusterReconciler) reconcileTrustBundleRef(ctx context.Context, if err := r.Client.Update(ctx, configMap); err != nil { log.Error(err, "error occurred while updating trust bundle configmap", "nutanixCluster", nutanixCluster) - conditions.MarkFalse(nutanixCluster, infrav1.TrustBundleSecretOwnerSetCondition, infrav1.TrustBundleSecretOwnerSetFailed, capiv1.ConditionSeverityError, err.Error()) + conditions.MarkFalse(nutanixCluster, infrav1.TrustBundleSecretOwnerSetCondition, infrav1.TrustBundleSecretOwnerSetFailed, capiv1.ConditionSeverityError, err.Error()) //nolint:govet // error will not be a constant return err } diff --git a/controllers/nutanixmachine_controller.go b/controllers/nutanixmachine_controller.go index 9b47b3d857..21e9d75df8 100644 --- a/controllers/nutanixmachine_controller.go +++ b/controllers/nutanixmachine_controller.go @@ -321,7 +321,7 @@ func (r *NutanixMachineReconciler) reconcileDelete(rctx *nctx.MachineContext) (r if err != nil { errorMsg := fmt.Errorf("error finding VM %s with UUID %s: %v", vmName, vmUUID, err) log.Error(errorMsg, "error finding VM") - conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMProvisionedCondition, infrav1.DeletionFailed, capiv1.ConditionSeverityWarning, errorMsg.Error()) + conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMProvisionedCondition, infrav1.DeletionFailed, capiv1.ConditionSeverityWarning, errorMsg.Error()) //nolint:govet // error will not be a constant return reconcile.Result{}, errorMsg } @@ -346,7 +346,7 @@ func (r *NutanixMachineReconciler) reconcileDelete(rctx *nctx.MachineContext) (r if err != nil { errorMsg := fmt.Errorf("error occurred fetching task UUID from VM: %v", err) log.Error(errorMsg, "error fetching task UUID") - conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMProvisionedCondition, infrav1.DeletionFailed, capiv1.ConditionSeverityWarning, errorMsg.Error()) + conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMProvisionedCondition, infrav1.DeletionFailed, capiv1.ConditionSeverityWarning, errorMsg.Error()) //nolint:govet // error will not be a constant return reconcile.Result{}, errorMsg } @@ -379,7 +379,7 @@ func (r *NutanixMachineReconciler) reconcileDelete(rctx *nctx.MachineContext) (r if err := r.detachVolumeGroups(rctx, vmName, vmUUID, vm.Spec.Resources.DiskList); err != nil { err := fmt.Errorf("failed to detach volume groups from VM %s with UUID %s: %v", vmName, vmUUID, err) log.Error(err, "failed to detach volume groups from VM") - conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMProvisionedCondition, infrav1.VolumeGroupDetachFailed, capiv1.ConditionSeverityWarning, err.Error()) + conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMProvisionedCondition, infrav1.VolumeGroupDetachFailed, capiv1.ConditionSeverityWarning, err.Error()) //nolint:govet // error will not be a constant return reconcile.Result{}, err } @@ -395,7 +395,7 @@ func (r *NutanixMachineReconciler) reconcileDelete(rctx *nctx.MachineContext) (r if err != nil { err := fmt.Errorf("failed to delete VM %s with UUID %s: %v", vmName, vmUUID, err) log.Error(err, "failed to delete VM") - conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMProvisionedCondition, infrav1.DeletionFailed, capiv1.ConditionSeverityWarning, err.Error()) + conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMProvisionedCondition, infrav1.DeletionFailed, capiv1.ConditionSeverityWarning, err.Error()) //nolint:govet // error will not be a constant return reconcile.Result{}, err } @@ -501,7 +501,7 @@ func (r *NutanixMachineReconciler) reconcileNormal(rctx *nctx.MachineContext) (r if err := r.assignAddressesToMachine(rctx, vm); err != nil { errorMsg := fmt.Errorf("failed to assign addresses to VM %s with UUID %s...: %v", rctx.Machine.Name, rctx.NutanixMachine.Status.VmUUID, err) log.Error(errorMsg, "failed to assign addresses") - conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMAddressesAssignedCondition, infrav1.VMAddressesFailed, capiv1.ConditionSeverityError, err.Error()) + conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMAddressesAssignedCondition, infrav1.VMAddressesFailed, capiv1.ConditionSeverityError, err.Error()) //nolint:govet // error will not be a constant return reconcile.Result{}, errorMsg } @@ -915,7 +915,7 @@ func (r *NutanixMachineReconciler) addBootTypeToVM(rctx *nctx.MachineContext, vm if bootType != "" { if bootType != infrav1.NutanixBootTypeLegacy && bootType != infrav1.NutanixBootTypeUEFI { errorMsg := fmt.Errorf("boot type must be %s or %s but was %s", string(infrav1.NutanixBootTypeLegacy), string(infrav1.NutanixBootTypeUEFI), bootType) - conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMProvisionedCondition, infrav1.VMBootTypeInvalid, capiv1.ConditionSeverityError, errorMsg.Error()) + conditions.MarkFalse(rctx.NutanixMachine, infrav1.VMProvisionedCondition, infrav1.VMBootTypeInvalid, capiv1.ConditionSeverityError, errorMsg.Error()) //nolint:govet // error will not be a constant return errorMsg } @@ -942,7 +942,7 @@ func (r *NutanixMachineReconciler) addVMToProject(rctx *nctx.MachineContext, vmM if vmMetadata == nil { errorMsg := fmt.Errorf("metadata cannot be nil when adding VM %s to project", vmName) log.Error(errorMsg, "failed to add vm to project") - conditions.MarkFalse(rctx.NutanixMachine, infrav1.ProjectAssignedCondition, infrav1.ProjectAssignationFailed, capiv1.ConditionSeverityError, errorMsg.Error()) + conditions.MarkFalse(rctx.NutanixMachine, infrav1.ProjectAssignedCondition, infrav1.ProjectAssignationFailed, capiv1.ConditionSeverityError, errorMsg.Error()) //nolint:govet // error will not be a constant return errorMsg } @@ -950,7 +950,7 @@ func (r *NutanixMachineReconciler) addVMToProject(rctx *nctx.MachineContext, vmM if err != nil { errorMsg := fmt.Errorf("error occurred while searching for project for VM %s: %v", vmName, err) log.Error(errorMsg, "error occurred while searching for project") - conditions.MarkFalse(rctx.NutanixMachine, infrav1.ProjectAssignedCondition, infrav1.ProjectAssignationFailed, capiv1.ConditionSeverityError, errorMsg.Error()) + conditions.MarkFalse(rctx.NutanixMachine, infrav1.ProjectAssignedCondition, infrav1.ProjectAssignationFailed, capiv1.ConditionSeverityError, errorMsg.Error()) //nolint:govet // error will not be a constant return errorMsg }