Merge pull request #13336 from rook/mergify/bp/release-1.13/pr-13324

core: Fix golang linter issues with variables in loops and update linter version (backport #13324)
This commit is contained in:
Travis Nielsen authored and GitHub committed 2023-12-05 15:08:37 -07:00
commit 79bfd831c1
9 files changed
+17 -12

No files matched your search

+3 -3
View File
@@ -29,12 +29,12 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: "1.21"
go-version: "1.20"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.53
version: v1.55
# Optional: working directory, useful for monorepos
# working-directory: somedir
@@ -51,6 +51,6 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.21.4"
go-version: "1.21.4"
- name: govulncheck
uses: golang/govulncheck-action@v1
+2 -2
View File
@@ -279,8 +279,8 @@ func (vt *ValidationTest) getImagePullPodCountPerNodeType(
}
numsScheduled := perNodeTypeCount{}
for _, d := range dsets.Items {
nodeType := getNodeType(&d.ObjectMeta)
for i, d := range dsets.Items {
nodeType := getNodeType(&dsets.Items[i].ObjectMeta)
numScheduled := d.Status.CurrentNumberScheduled
if numScheduled == 0 {
return emptyCount, fmt.Errorf("image pull daemonset for node type %q expects zero scheduled pods", nodeType)
+1 -1
View File
@@ -208,7 +208,7 @@ func (r *ReconcileCSI) reconcile(request reconcile.Request) (reconcile.Result, e
// If so deploy the plugin holder with the fsid attached
if holderEnabled {
// Load cluster info for later use in updating the ceph-csi configmap
clusterInfo, _, _, err := opcontroller.LoadClusterInfo(r.context, r.opManagerContext, cluster.Namespace, &cluster.Spec)
clusterInfo, _, _, err := opcontroller.LoadClusterInfo(r.context, r.opManagerContext, cluster.Namespace, &cephClusters.Items[i].Spec)
if err != nil {
// This avoids a requeue with exponential backoff and allows the controller to reconcile
// more quickly when the cluster is ready.
+2 -2
View File
@@ -709,9 +709,9 @@ func (r *ReconcileCSI) applyCephClusterNetworkConfig(ctx context.Context, object
if err != nil {
return errors.Wrap(err, "failed to find CephClusters")
}
for _, cephCluster := range cephClusters.Items {
for i, cephCluster := range cephClusters.Items {
if cephCluster.Spec.Network.IsMultus() {
err = k8sutil.ApplyMultus(cephCluster.GetNamespace(), &cephCluster.Spec.Network, objectMeta)
err = k8sutil.ApplyMultus(cephCluster.GetNamespace(), &cephClusters.Items[i].Spec.Network, objectMeta)
if err != nil {
return errors.Wrapf(err, "failed to apply multus configuration to CephCluster %q", cephCluster.Name)
}
@@ -152,6 +152,7 @@ const (
"ceph version 17.2.1 (0000000000000000) quincy (stable)": 3
}
}`
//nolint:gosec // only test values, not a real secret
userCreateJSON = `{
"user_id": "my-user",
"display_name": "my-user",
@@ -40,6 +40,7 @@ import (
)
const (
//nolint:gosec // only test values, not a real secret
dashboardAdminCreateJSON = `{
"user_id": "dashboard-admin",
"display_name": "dashboard-admin",
@@ -43,9 +43,10 @@ import (
)
var (
name = "topic-a"
namespace = "rook-ceph"
store = "test-store"
name = "topic-a"
namespace = "rook-ceph"
store = "test-store"
//nolint:gosec // only test values, not a real secret
userCreateJSON = `{
"user_id": "rgw-admin-ops-user",
"display_name": "RGW Admin Ops User",
@@ -49,6 +49,7 @@ import (
)
const (
//nolint:gosec // only test values, not a real secret
userCreateJSON = `{
"user_id": "my-user",
"display_name": "my-user",
+2 -1
View File
@@ -96,7 +96,8 @@ func TestExpandPVCIfRequired(t *testing.T) {
for _, tc := range testcases {
desiredPVC.Spec.Resources.Requests[v1.ResourceStorage] = apiresource.MustParse(tc.currentPVCSize)
storageClass.AllowVolumeExpansion = &tc.expansionAllowed
expansionAllowed := tc.expansionAllowed
storageClass.AllowVolumeExpansion = &expansionAllowed
// create fake client with PVC
cl := fake.NewClientBuilder().WithRuntimeObjects(desiredPVC, storageClass).Build()