core: fix golang linter issues with variables in loops
Loop variables cannot be reliably uses since they will
change with each iteration. Update these loop variable
uses to be safe by indexing the slice rather than
using the loop variable directly.
Also suppress the linter issues for passwords used
in tests.
Signed-off-by: travisn <tnielsen@redhat.com>
(cherry picked from commit 6f8e42422d)
This commit is contained in:
1 parent
fda9381ee4
commit
83caa1b2bf
9 files changed
+17
-12
No files matched your search
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user