diff --git a/e2e/pod.go b/e2e/pod.go index 400002233..f98518996 100644 --- a/e2e/pod.go +++ b/e2e/pod.go @@ -210,8 +210,7 @@ func execCommandInPodAndAllowFail(f *framework.Framework, c, ns string, opt *met func loadApp(path string) (*v1.Pod, error) { app := v1.Pod{} - err := unmarshal(path, &app) - if err != nil { + if err := unmarshal(path, &app); err != nil { return nil, err } for i := range app.Spec.Containers { diff --git a/e2e/upgrade.go b/e2e/upgrade.go index d9a971697..91cab28b2 100644 --- a/e2e/upgrade.go +++ b/e2e/upgrade.go @@ -27,8 +27,7 @@ func upgradeCSI(version string) error { // upgradeAndDeployCSI upgrades the CSI to a specific release. func upgradeAndDeployCSI(version, testtype string) error { - err := upgradeCSI(version) - if err != nil { + if err := upgradeCSI(version); err != nil { return fmt.Errorf("failed to upgrade driver %w", err) } switch testtype { diff --git a/internal/csi-common/utils.go b/internal/csi-common/utils.go index 36b8c3dc2..439796273 100644 --- a/internal/csi-common/utils.go +++ b/internal/csi-common/utils.go @@ -153,8 +153,7 @@ var id uint64 func contextIDInjector(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { atomic.AddUint64(&id, 1) ctx = context.WithValue(ctx, util.CtxKey, id) - reqID := getReqID(req) - if reqID != "" { + if reqID := getReqID(req); reqID != "" { ctx = context.WithValue(ctx, util.ReqID, reqID) } return handler(ctx, req) diff --git a/internal/rbd/rbd_journal.go b/internal/rbd/rbd_journal.go index c534afe2f..9048a539e 100644 --- a/internal/rbd/rbd_journal.go +++ b/internal/rbd/rbd_journal.go @@ -278,7 +278,7 @@ func (rv *rbdVolume) Exists(ctx context.Context, parentVol *rbdVolume) (bool, er // NOTE: Return volsize should be on-disk volsize, not request vol size, so // save it for size checks before fetching image data - requestSize := rv.VolSize + requestSize := rv.VolSize //nolint:ifshort // FIXME: rename and split function into helpers // Fetch on-disk image attributes and compare against request err = rv.getImageInfo() if err != nil { diff --git a/internal/util/conn_pool.go b/internal/util/conn_pool.go index 89d03379e..f5672696a 100644 --- a/internal/util/conn_pool.go +++ b/internal/util/conn_pool.go @@ -156,8 +156,7 @@ func (cp *ConnPool) Get(monitors, user, keyfile string) (*rados.Conn, error) { cp.lock.Lock() defer cp.lock.Unlock() - oldConn := cp.getConn(unique) - if oldConn != nil { + if oldConn := cp.getConn(unique); oldConn != nil { // there was a race, oldConn already exists ce.destroy() return oldConn, nil diff --git a/internal/util/conn_pool_test.go b/internal/util/conn_pool_test.go index 95c47fdd6..f12183c7b 100644 --- a/internal/util/conn_pool_test.go +++ b/internal/util/conn_pool_test.go @@ -62,8 +62,7 @@ func (cp *ConnPool) fakeGet(monitors, user, keyfile string) (*rados.Conn, string cp.lock.Lock() defer cp.lock.Unlock() - oldConn := cp.getConn(unique) - if oldConn != nil { + if oldConn := cp.getConn(unique); oldConn != nil { // there was a race, oldConn already exists ce.destroy() return oldConn, unique, nil diff --git a/internal/util/errors_test.go b/internal/util/errors_test.go index 5431ac02c..767cc07b1 100644 --- a/internal/util/errors_test.go +++ b/internal/util/errors_test.go @@ -64,8 +64,7 @@ func TestJoinErrors(t *testing.T) { assertErrorIs(x, errFoo, false) assertErrorIs(x, errBar, true) s1 := "w{w{w{x}}: w{w{foo: bar}}}" - s2 := w1w2Xw2FooBar.Error() - if s1 != s2 { + if s2 := w1w2Xw2FooBar.Error(); s1 != s2 { t.Errorf("%s != %s", s1, s2) } } diff --git a/internal/util/util.go b/internal/util/util.go index 955923db6..5223afc7a 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -47,9 +47,8 @@ func RoundOffVolSize(size int64) int64 { // size less than 1MiB will be round off to 1MiB. func RoundOffBytes(bytes int64) int64 { var num int64 - floatBytes := float64(bytes) // round off the value if its in decimal - if floatBytes < helpers.GiB { + if floatBytes := float64(bytes); floatBytes < helpers.GiB { num = int64(math.Ceil(floatBytes / helpers.MiB)) num *= helpers.MiB } else { @@ -142,8 +141,7 @@ func ValidateDriverName(driverName string) error { // 'utsname' structs 'release' component. func GetKernelVersion() (string, error) { utsname := unix.Utsname{} - err := unix.Uname(&utsname) - if err != nil { + if err := unix.Uname(&utsname); err != nil { return "", err } return strings.TrimRight(string(utsname.Release[:]), "\x00"), nil diff --git a/internal/util/vault_tokens.go b/internal/util/vault_tokens.go index 9ac1800ce..80090ccfc 100644 --- a/internal/util/vault_tokens.go +++ b/internal/util/vault_tokens.go @@ -188,8 +188,7 @@ func initVaultTokensKMS(args KMSInitializerArgs) (EncryptionKMS, error) { var err error config := args.Config - _, ok := config[kmsProviderKey] - if ok { + if _, ok := config[kmsProviderKey]; ok { // configuration comes from the ConfigMap, needs to be // converted to vaultTokenConf type config, err = transformConfig(config)