Skip to content

Commit

Permalink
Merge pull request #13336 from rook/mergify/bp/release-1.13/pr-13324
Browse files Browse the repository at this point in the history
core: Fix golang linter issues with variables in loops and update linter version (backport #13324)
  • Loading branch information
travisn committed Dec 5, 2023
2 parents c9f0297 + 83caa1b commit 79bfd83
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions pkg/daemon/multus/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/ceph/csi/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/ceph/csi/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/ceph/object/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/ceph/object/objectstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
)

const (
//nolint:gosec // only test values, not a real secret
dashboardAdminCreateJSON = `{
"user_id": "dashboard-admin",
"display_name": "dashboard-admin",
Expand Down
7 changes: 4 additions & 3 deletions pkg/operator/ceph/object/topic/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/ceph/object/user/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
)

const (
//nolint:gosec // only test values, not a real secret
userCreateJSON = `{
"user_id": "my-user",
"display_name": "my-user",
Expand Down
3 changes: 2 additions & 1 deletion pkg/operator/k8sutil/pvc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 79bfd83

Please sign in to comment.