Repository: rook/rook
Pull request #15879 (2025-05-20 15:01:25)

core: fix golangci-lint check ST1023 QF1011
This PR updates variable declarations to follow Go idiomatic style as enforced by `gofumpt` and `staticcheck`. Specifically:

- Removes explicit type declarations when the type can be inferred from the right-hand side.
- Replaces `var foo type = value` with the short declaration syntax `foo := value`.
- Cleans up `.golangci.yaml` by removing the ignored linter checks for these cases (`ST1023`, `QF1011`), since the code has  been updated to comply with them.

**Checklist:**

- [x] **Commit Message Formatting**: Commit titles and messages follow guidelines in the [developer guide](https://rook.io/docs/rook/latest/Contributing/development-flow/#commit-structure).
- [x] Reviewed the developer guide on [Submitting a Pull Request](https://rook.io/docs/rook/latest/Contributing/development-flow/#submitting-a-pull-request)
- [ ] [Pending release notes](https://github.com/rook/rook/blob/master/PendingReleaseNotes.md) updated with breaking and/or notable changes for the next minor release.
- [ ] Documentation has been updated, if necessary.
- [ ] Unit tests have been added, if necessary.
- [ ] Integration tests have been added, if necessary.



Patch:
diff --git a/.golangci.yaml b/.golangci.yaml
index 2d48587e2..433ae4616 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -25,18 +25,12 @@ linters:
       - linters:
           - staticcheck
         text: "QF1007:" # could merge conditional assignment into variable declaration (staticcheck)
-      - linters:
-          - staticcheck
-        text: "ST1023:" # should omit type string from declaration; it will be inferred from the right-hand side (staticcheck)
       - linters:
           - staticcheck
         text: "QF1001:" # could apply De Morgan's law (staticcheck)
       - linters:
           - staticcheck
         text: "QF1002:" # could use tagged switch on args[0] (staticcheck)
-      - linters:
-          - staticcheck
-        text: "QF1011:" # could omit type string from declaration; it will be inferred from the right-hand side (staticcheck)
       - linters:
           - staticcheck
         text: "QF1004:" # could use strings.ReplaceAll instead (staticcheck)
diff --git a/Documentation/Helm-Charts/operator-chart.md b/Documentation/Helm-Charts/operator-chart.md
index 09cb920d5..64afdc653 100644
--- a/Documentation/Helm-Charts/operator-chart.md
+++ b/Documentation/Helm-Charts/operator-chart.md
@@ -50,7 +50,7 @@ The following table lists the configurable parameters of the rook-operator chart
 | `containerSecurityContext` | Set the container security context for the operator | `{"capabilities":{"drop":["ALL"]},"runAsGroup":2016,"runAsNonRoot":true,"runAsUser":2016}` |
 | `crds.enabled` | Whether the helm chart should create and update the CRDs. If false, the CRDs must be managed independently with deploy/examples/crds.yaml. **WARNING** Only set during first deployment. If later disabled the cluster may be DESTROYED. If the CRDs are deleted in this case, see [the disaster recovery guide](https://rook.io/docs/rook/latest/Troubleshooting/disaster-recovery/#restoring-crds-after-deletion) to restore them. | `true` |
 | `csi.attacher.repository` | Kubernetes CSI Attacher image repository | `"registry.k8s.io/sig-storage/csi-attacher"` |
-| `csi.attacher.tag` | Attacher image tag | `"v4.8.1"` |
+| `csi.attacher.tag` | Attacher image tag | `"v4.8.0"` |
 | `csi.cephFSAttachRequired` | Whether to skip any attach operation altogether for CephFS PVCs. See more details [here](https://kubernetes-csi.github.io/docs/skip-attach.html#skip-attach-with-csi-driver-object). If cephFSAttachRequired is set to false it skips the volume attachments and makes the creation of pods using the CephFS PVC fast. **WARNING** It's highly discouraged to use this for CephFS RWO volumes. Refer to this [issue](https://github.com/kubernetes/kubernetes/issues/103305) for more details. | `true` |
 | `csi.cephFSFSGroupPolicy` | Policy for modifying a volume's ownership or permissions when the CephFS PVC is being mounted. supported values are documented at https://kubernetes-csi.github.io/docs/support-fsgroup.html | `"File"` |
 | `csi.cephFSKernelMountOptions` | Set CephFS Kernel mount options to use https://docs.ceph.com/en/latest/man/8/mount.ceph/#options. Set to "ms_mode=secure" when connections.encrypted is enabled in CephCluster CR | `nil` |
@@ -110,7 +110,7 @@ The following table lists the configurable parameters of the rook-operator chart
 | `csi.pluginPriorityClassName` | PriorityClassName to be set on csi driver plugin pods | `"system-node-critical"` |
 | `csi.pluginTolerations` | Array of tolerations in YAML format which will be added to CephCSI plugin DaemonSet | `nil` |
 | `csi.provisioner.repository` | Kubernetes CSI provisioner image repository | `"registry.k8s.io/sig-storage/csi-provisioner"` |
-| `csi.provisioner.tag` | Provisioner image tag | `"v5.2.0"` |
+| `csi.provisioner.tag` | Provisioner image tag | `"v5.1.0"` |
 | `csi.provisionerNodeAffinity` | The node labels for affinity of the CSI provisioner deployment [^1] | `nil` |
 | `csi.provisionerPriorityClassName` | PriorityClassName to be set on csi driver provisioner pods | `"system-cluster-critical"` |
 | `csi.provisionerReplicas` | Set replicas for csi provisioner deployment | `2` |
@@ -124,14 +124,14 @@ The following table lists the configurable parameters of the rook-operator chart
 | `csi.registrar.repository` | Kubernetes CSI registrar image repository | `"registry.k8s.io/sig-storage/csi-node-driver-registrar"` |
 | `csi.registrar.tag` | Registrar image tag | `"v2.13.0"` |
 | `csi.resizer.repository` | Kubernetes CSI resizer image repository | `"registry.k8s.io/sig-storage/csi-resizer"` |
-| `csi.resizer.tag` | Resizer image tag | `"v1.13.2"` |
+| `csi.resizer.tag` | Resizer image tag | `"v1.13.1"` |
 | `csi.serviceMonitor.enabled` | Enable ServiceMonitor for Ceph CSI drivers | `false` |
 | `csi.serviceMonitor.interval` | Service monitor scrape interval | `"10s"` |
 | `csi.serviceMonitor.labels` | ServiceMonitor additional labels | `{}` |
 | `csi.serviceMonitor.namespace` | Use a different namespace for the ServiceMonitor | `nil` |
 | `csi.sidecarLogLevel` | Set logging level for Kubernetes-csi sidecar containers. Supported values from 0 to 5. 0 for general useful logs (the default), 5 for trace level verbosity. | `0` |
 | `csi.snapshotter.repository` | Kubernetes CSI snapshotter image repository | `"registry.k8s.io/sig-storage/csi-snapshotter"` |
-| `csi.snapshotter.tag` | Snapshotter image tag | `"v8.2.1"` |
+| `csi.snapshotter.tag` | Snapshotter image tag | `"v8.2.0"` |
 | `csi.topology.domainLabels` | domainLabels define which node labels to use as domains for CSI nodeplugins to advertise their domains | `nil` |
 | `csi.topology.enabled` | Enable topology based provisioning | `false` |
 | `currentNamespaceOnly` | Whether the operator should watch cluster CRD in its own namespace or not | `false` |
diff --git a/Documentation/Storage-Configuration/Ceph-CSI/custom-images.md b/Documentation/Storage-Configuration/Ceph-CSI/custom-images.md
index 72058188e..955f22aeb 100644
--- a/Documentation/Storage-Configuration/Ceph-CSI/custom-images.md
+++ b/Documentation/Storage-Configuration/Ceph-CSI/custom-images.md
@@ -20,10 +20,10 @@ The default upstream images are included below, which you can change to your des
 ```yaml
 ROOK_CSI_CEPH_IMAGE: "quay.io/cephcsi/cephcsi:v3.14.0"
 ROOK_CSI_REGISTRAR_IMAGE: "registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.13.0"
-ROOK_CSI_PROVISIONER_IMAGE: "registry.k8s.io/sig-storage/csi-provisioner:v5.2.0"
-ROOK_CSI_ATTACHER_IMAGE: "registry.k8s.io/sig-storage/csi-attacher:v4.8.1"
-ROOK_CSI_RESIZER_IMAGE: "registry.k8s.io/sig-storage/csi-resizer:v1.13.2"
-ROOK_CSI_SNAPSHOTTER_IMAGE: "registry.k8s.io/sig-storage/csi-snapshotter:v8.2.1"
+ROOK_CSI_PROVISIONER_IMAGE: "registry.k8s.io/sig-storage/csi-provisioner:v5.1.0"
+ROOK_CSI_ATTACHER_IMAGE: "registry.k8s.io/sig-storage/csi-attacher:v4.8.0"
+ROOK_CSI_RESIZER_IMAGE: "registry.k8s.io/sig-storage/csi-resizer:v1.13.1"
+ROOK_CSI_SNAPSHOTTER_IMAGE: "registry.k8s.io/sig-storage/csi-snapshotter:v8.2.0"
 ROOK_CSIADDONS_IMAGE: "quay.io/csiaddons/k8s-sidecar:v0.12.0"
 ```
 
diff --git a/deploy/charts/rook-ceph/values.yaml b/deploy/charts/rook-ceph/values.yaml
index 123eb1b15..a6b304e32 100644
--- a/deploy/charts/rook-ceph/values.yaml
+++ b/deploy/charts/rook-ceph/values.yaml
@@ -501,25 +501,25 @@ csi:
     # -- Kubernetes CSI provisioner image repository
     repository: registry.k8s.io/sig-storage/csi-provisioner
     # -- Provisioner image tag
-    tag: v5.2.0
+    tag: v5.1.0
 
   snapshotter:
     # -- Kubernetes CSI snapshotter image repository
     repository: registry.k8s.io/sig-storage/csi-snapshotter
     # -- Snapshotter image tag
-    tag: v8.2.1
+    tag: v8.2.0
 
   attacher:
     # -- Kubernetes CSI Attacher image repository
     repository: registry.k8s.io/sig-storage/csi-attacher
     # -- Attacher image tag
-    tag: v4.8.1
+    tag: v4.8.0
 
   resizer:
     # -- Kubernetes CSI resizer image repository
     repository: registry.k8s.io/sig-storage/csi-resizer
     # -- Resizer image tag
-    tag: v1.13.2
+    tag: v1.13.1
 
   # -- Image pull policy
   imagePullPolicy: IfNotPresent
diff --git a/deploy/examples/images.txt b/deploy/examples/images.txt
index 8f7bb0890..0de066e86 100644
--- a/deploy/examples/images.txt
+++ b/deploy/examples/images.txt
@@ -4,8 +4,8 @@
  quay.io/ceph/cosi:v0.1.2
  quay.io/cephcsi/cephcsi:v3.14.0
  quay.io/csiaddons/k8s-sidecar:v0.12.0
- registry.k8s.io/sig-storage/csi-attacher:v4.8.1
+ registry.k8s.io/sig-storage/csi-attacher:v4.8.0
  registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.13.0
- registry.k8s.io/sig-storage/csi-provisioner:v5.2.0
- registry.k8s.io/sig-storage/csi-resizer:v1.13.2
- registry.k8s.io/sig-storage/csi-snapshotter:v8.2.1
+ registry.k8s.io/sig-storage/csi-provisioner:v5.1.0
+ registry.k8s.io/sig-storage/csi-resizer:v1.13.1
+ registry.k8s.io/sig-storage/csi-snapshotter:v8.2.0
diff --git a/deploy/examples/operator-openshift.yaml b/deploy/examples/operator-openshift.yaml
index d0569fd0d..095a0ef06 100644
--- a/deploy/examples/operator-openshift.yaml
+++ b/deploy/examples/operator-openshift.yaml
@@ -191,10 +191,10 @@ data:
   # these images to the desired release of the CSI driver.
   # ROOK_CSI_CEPH_IMAGE: "quay.io/cephcsi/cephcsi:v3.14.0"
   # ROOK_CSI_REGISTRAR_IMAGE: "registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.13.0"
-  # ROOK_CSI_RESIZER_IMAGE: "registry.k8s.io/sig-storage/csi-resizer:v1.13.2"
-  # ROOK_CSI_PROVISIONER_IMAGE: "registry.k8s.io/sig-storage/csi-provisioner:v5.2.0"
-  # ROOK_CSI_SNAPSHOTTER_IMAGE: "registry.k8s.io/sig-storage/csi-snapshotter:v8.2.1"
-  # ROOK_CSI_ATTACHER_IMAGE: "registry.k8s.io/sig-storage/csi-attacher:v4.8.1"
+  # ROOK_CSI_RESIZER_IMAGE: "registry.k8s.io/sig-storage/csi-resizer:v1.13.1"
+  # ROOK_CSI_PROVISIONER_IMAGE: "registry.k8s.io/sig-storage/csi-provisioner:v5.1.0"
+  # ROOK_CSI_SNAPSHOTTER_IMAGE: "registry.k8s.io/sig-storage/csi-snapshotter:v8.2.0"
+  # ROOK_CSI_ATTACHER_IMAGE: "registry.k8s.io/sig-storage/csi-attacher:v4.8.0"
 
   # (Optional) set user created priorityclassName for csi plugin pods.
   CSI_PLUGIN_PRIORITY_CLASSNAME: "system-node-critical"
diff --git a/deploy/examples/operator.yaml b/deploy/examples/operator.yaml
index 93e068442..256549683 100644
--- a/deploy/examples/operator.yaml
+++ b/deploy/examples/operator.yaml
@@ -121,10 +121,10 @@ data:
   # these images to the desired release of the CSI driver.
   # ROOK_CSI_CEPH_IMAGE: "quay.io/cephcsi/cephcsi:v3.14.0"
   # ROOK_CSI_REGISTRAR_IMAGE: "registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.13.0"
-  # ROOK_CSI_RESIZER_IMAGE: "registry.k8s.io/sig-storage/csi-resizer:v1.13.2"
-  # ROOK_CSI_PROVISIONER_IMAGE: "registry.k8s.io/sig-storage/csi-provisioner:v5.2.0"
-  # ROOK_CSI_SNAPSHOTTER_IMAGE: "registry.k8s.io/sig-storage/csi-snapshotter:v8.2.1"
-  # ROOK_CSI_ATTACHER_IMAGE: "registry.k8s.io/sig-storage/csi-attacher:v4.8.1"
+  # ROOK_CSI_RESIZER_IMAGE: "registry.k8s.io/sig-storage/csi-resizer:v1.13.1"
+  # ROOK_CSI_PROVISIONER_IMAGE: "registry.k8s.io/sig-storage/csi-provisioner:v5.1.0"
+  # ROOK_CSI_SNAPSHOTTER_IMAGE: "registry.k8s.io/sig-storage/csi-snapshotter:v8.2.0"
+  # ROOK_CSI_ATTACHER_IMAGE: "registry.k8s.io/sig-storage/csi-attacher:v4.8.0"
 
   # To indicate the image pull policy to be applied to all the containers in the csi driver pods.
   # ROOK_CSI_IMAGE_PULL_POLICY: "IfNotPresent"
diff --git a/pkg/operator/ceph/controller/network.go b/pkg/operator/ceph/controller/network.go
index 6671bea09..55b491c10 100644
--- a/pkg/operator/ceph/controller/network.go
+++ b/pkg/operator/ceph/controller/network.go
@@ -117,7 +117,7 @@ func setNetworkCIDRs(clusterdCtx *clusterd.Context, clusterInfo *cephclient.Clus
 
 	logger.Infof("ensuring cluster %q %q network is configured to use CIDR(s) %q", ns, cephNet, settingVal)
 	if len(cidrs) > 0 {
-		var s monStoreInterface = getMonStoreFunc(clusterdCtx, clusterInfo)
+		s := getMonStoreFunc(clusterdCtx, clusterInfo)
 		changed, err := s.SetIfChanged("global", settingKey, settingVal)
 		if err != nil {
 			return errors.Wrapf(err, "failed to set CIDR(s) %q on cluster %q %q network", settingVal, cephNet, ns)
diff --git a/pkg/operator/ceph/csi/csi.go b/pkg/operator/ceph/csi/csi.go
index 49752f3a9..231c5c041 100644
--- a/pkg/operator/ceph/csi/csi.go
+++ b/pkg/operator/ceph/csi/csi.go
@@ -172,9 +172,9 @@ func (r *ReconcileCSI) setParams() error {
 		CSIParam.EnableCSIEncryption = true
 	}
 
-	CSIParam.CSIEnableMetadata = true
-	if strings.EqualFold(k8sutil.GetOperatorSetting("CSI_ENABLE_METADATA", "true"), "false") {
-		CSIParam.CSIEnableMetadata = false
+	CSIParam.CSIEnableMetadata = false
+	if strings.EqualFold(k8sutil.GetOperatorSetting("CSI_ENABLE_METADATA", "false"), "true") {
+		CSIParam.CSIEnableMetadata = true
 	}
 
 	if strings.EqualFold(k8sutil.GetOperatorSetting("CSI_CEPHFS_PLUGIN_UPDATE_STRATEGY", rollingUpdate), onDelete) {
diff --git a/pkg/operator/ceph/csi/spec.go b/pkg/operator/ceph/csi/spec.go
index 84a3cef1e..e7d4c979f 100644
--- a/pkg/operator/ceph/csi/spec.go
+++ b/pkg/operator/ceph/csi/spec.go
@@ -134,10 +134,10 @@ var (
 	// image names
 	DefaultCSIPluginImage   = "quay.io/cephcsi/cephcsi:v3.14.0"
 	DefaultRegistrarImage   = "registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.13.0"
-	DefaultProvisionerImage = "registry.k8s.io/sig-storage/csi-provisioner:v5.2.0"
-	DefaultAttacherImage    = "registry.k8s.io/sig-storage/csi-attacher:v4.8.1"
-	DefaultSnapshotterImage = "registry.k8s.io/sig-storage/csi-snapshotter:v8.2.1"
-	DefaultResizerImage     = "registry.k8s.io/sig-storage/csi-resizer:v1.13.2"
+	DefaultProvisionerImage = "registry.k8s.io/sig-storage/csi-provisioner:v5.1.0"
+	DefaultAttacherImage    = "registry.k8s.io/sig-storage/csi-attacher:v4.8.0"
+	DefaultSnapshotterImage = "registry.k8s.io/sig-storage/csi-snapshotter:v8.2.0"
+	DefaultResizerImage     = "registry.k8s.io/sig-storage/csi-resizer:v1.13.1"
 	DefaultCSIAddonsImage   = "quay.io/csiaddons/k8s-sidecar:v0.12.0"
 
 	// image pull policy


Test patch:
diff --git a/pkg/operator/ceph/client/controller_test.go b/pkg/operator/ceph/client/controller_test.go
index 0e61ab872..0a04e1875 100644
--- a/pkg/operator/ceph/client/controller_test.go
+++ b/pkg/operator/ceph/client/controller_test.go
@@ -17,7 +17,6 @@ limitations under the License.
 package client
 
 import (
-	"bytes"
 	"context"
 	"os"
 	"strings"
@@ -83,9 +82,7 @@ func TestGenerateClient(t *testing.T) {
 	}
 
 	client, caps := genClientEntity(p)
-	equal := bytes.Compare([]byte(client), []byte("client.client1"))
-	var res bool = equal == 0
-	assert.True(t, res)
+	assert.Equal(t, []byte(client), []byte("client.client1"))
 	assert.True(t, strings.Contains(strings.Join(caps, " "), "osd allow *"))
 	assert.True(t, strings.Contains(strings.Join(caps, " "), "mon allow rw"))
 	assert.True(t, strings.Contains(strings.Join(caps, " "), "mds allow rwx"))
@@ -102,9 +99,7 @@ func TestGenerateClient(t *testing.T) {
 	}
 
 	client, _ = genClientEntity(p2)
-	equal = bytes.Compare([]byte(client), []byte("client.client2"))
-	res = equal == 0
-	assert.True(t, res)
+	assert.Equal(t, []byte(client), []byte("client.client2"))
 }
 
 func TestCephClientController(t *testing.T) {
diff --git a/pkg/operator/ceph/controller/controller_utils_test.go b/pkg/operator/ceph/controller/controller_utils_test.go
index 7ad0cfb41..e8e8a6180 100644
--- a/pkg/operator/ceph/controller/controller_utils_test.go
+++ b/pkg/operator/ceph/controller/controller_utils_test.go
@@ -148,7 +148,7 @@ func TestSetEnforceHostNetwork(t *testing.T) {
 	assert.False(t, EnforceHostNetwork())
 
 	// test invalid setting
-	var value string = "foo"
+	value := "foo"
 	logger.Infof("testing invalid value'%v' for %v", value, enforceHostNetworkSettingName)
 	os.Setenv(enforceHostNetworkSettingName, value)
 	SetEnforceHostNetwork()
@@ -176,7 +176,7 @@ func TestSetRevisionHistoryLimit(t *testing.T) {
 		assert.Nil(t, RevisionHistoryLimit())
 	})
 
-	var value string = "foo"
+	value := "foo"
 	t.Run("ROOK_REVISION_HISTORY_LIMIT: test invalid value 'foo'", func(t *testing.T) {
 		os.Setenv(revisionHistoryLimitSettingName, value)
 		SetRevisionHistoryLimit()
diff --git a/pkg/operator/ceph/csi/operator_config_test.go b/pkg/operator/ceph/csi/operator_config_test.go
index 7f16139a6..a260a628f 100644
--- a/pkg/operator/ceph/csi/operator_config_test.go
+++ b/pkg/operator/ceph/csi/operator_config_test.go
@@ -87,5 +87,5 @@ func TestReconcileCSI_createOrUpdateOperatorConfig(t *testing.T) {
 
 	err = cl.Get(context.TODO(), types.NamespacedName{Name: opConfigCRName, Namespace: r.opConfig.OperatorNamespace}, opConfig)
 	assert.NoError(t, err)
-	assert.Equal(t, *opConfig.Spec.DriverSpecDefaults.EnableMetadata, true)
+	assert.Equal(t, *opConfig.Spec.DriverSpecDefaults.EnableMetadata, false)
 }
diff --git a/pkg/operator/k8sutil/resources_test.go b/pkg/operator/k8sutil/resources_test.go
index 78bcf69f7..debd7b6aa 100644
--- a/pkg/operator/k8sutil/resources_test.go
+++ b/pkg/operator/k8sutil/resources_test.go
@@ -72,7 +72,7 @@ func TestMergeResourceRequirements(t *testing.T) {
 }
 
 func TestYamlToContainerResourceArray(t *testing.T) {
-	var validData string = `
+	validData := `
 - name: rbdplugin
   resource:
     requests:
@@ -93,7 +93,7 @@ func TestYamlToContainerResourceArray(t *testing.T) {
 	assert.Len(t, res, 2)
 	assert.NoError(t, err)
 
-	var invalidData string = `
+	invalidData := `
 	invalid:
 	  data: 512Mi
 	invalid:
@@ -105,7 +105,7 @@ func TestYamlToContainerResourceArray(t *testing.T) {
 }
 
 func TestYamlToContainerResource(t *testing.T) {
-	var validData string = `
+	validData := `
   resources:
     requests:
       memory: 512Mi
@@ -116,7 +116,7 @@ func TestYamlToContainerResource(t *testing.T) {
 	res, err := YamlToContainerResource(validData)
 	assert.NoError(t, err)
 	assert.Equal(t, res.Requests.Memory().String(), "512Mi")
-	var invalidData string = `
+	invalidData := `
 	invalid:
 	  data: 512Mi
 	invalid:
diff --git a/tests/framework/utils/snapshot.go b/tests/framework/utils/snapshot.go
index 2196ace52..00f4a6f10 100644
--- a/tests/framework/utils/snapshot.go
+++ b/tests/framework/utils/snapshot.go
@@ -27,7 +27,7 @@ import (
 const (
 	// snapshotterVersion from which the snapshotcontroller and CRD will be
 	// installed
-	snapshotterVersion = "v8.2.1"
+	snapshotterVersion = "v8.2.0"
 	repoURL            = "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter"
 	rbacPath           = "deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
 	controllerPath     = "deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"