mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
cleanup: address ifshort linter issues
This commit addresses ifshort linter issues which checks if short syntax for if-statements is possible. updates: #1586 Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
parent
6618e2012d
commit
b891e5585d
@ -210,8 +210,7 @@ func execCommandInPodAndAllowFail(f *framework.Framework, c, ns string, opt *met
|
|||||||
|
|
||||||
func loadApp(path string) (*v1.Pod, error) {
|
func loadApp(path string) (*v1.Pod, error) {
|
||||||
app := v1.Pod{}
|
app := v1.Pod{}
|
||||||
err := unmarshal(path, &app)
|
if err := unmarshal(path, &app); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for i := range app.Spec.Containers {
|
for i := range app.Spec.Containers {
|
||||||
|
@ -27,8 +27,7 @@ func upgradeCSI(version string) error {
|
|||||||
|
|
||||||
// upgradeAndDeployCSI upgrades the CSI to a specific release.
|
// upgradeAndDeployCSI upgrades the CSI to a specific release.
|
||||||
func upgradeAndDeployCSI(version, testtype string) error {
|
func upgradeAndDeployCSI(version, testtype string) error {
|
||||||
err := upgradeCSI(version)
|
if err := upgradeCSI(version); err != nil {
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to upgrade driver %w", err)
|
return fmt.Errorf("failed to upgrade driver %w", err)
|
||||||
}
|
}
|
||||||
switch testtype {
|
switch testtype {
|
||||||
|
@ -153,8 +153,7 @@ var id uint64
|
|||||||
func contextIDInjector(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
func contextIDInjector(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||||
atomic.AddUint64(&id, 1)
|
atomic.AddUint64(&id, 1)
|
||||||
ctx = context.WithValue(ctx, util.CtxKey, id)
|
ctx = context.WithValue(ctx, util.CtxKey, id)
|
||||||
reqID := getReqID(req)
|
if reqID := getReqID(req); reqID != "" {
|
||||||
if reqID != "" {
|
|
||||||
ctx = context.WithValue(ctx, util.ReqID, reqID)
|
ctx = context.WithValue(ctx, util.ReqID, reqID)
|
||||||
}
|
}
|
||||||
return handler(ctx, req)
|
return handler(ctx, req)
|
||||||
|
@ -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
|
// NOTE: Return volsize should be on-disk volsize, not request vol size, so
|
||||||
// save it for size checks before fetching image data
|
// 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
|
// Fetch on-disk image attributes and compare against request
|
||||||
err = rv.getImageInfo()
|
err = rv.getImageInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -156,8 +156,7 @@ func (cp *ConnPool) Get(monitors, user, keyfile string) (*rados.Conn, error) {
|
|||||||
|
|
||||||
cp.lock.Lock()
|
cp.lock.Lock()
|
||||||
defer cp.lock.Unlock()
|
defer cp.lock.Unlock()
|
||||||
oldConn := cp.getConn(unique)
|
if oldConn := cp.getConn(unique); oldConn != nil {
|
||||||
if oldConn != nil {
|
|
||||||
// there was a race, oldConn already exists
|
// there was a race, oldConn already exists
|
||||||
ce.destroy()
|
ce.destroy()
|
||||||
return oldConn, nil
|
return oldConn, nil
|
||||||
|
@ -62,8 +62,7 @@ func (cp *ConnPool) fakeGet(monitors, user, keyfile string) (*rados.Conn, string
|
|||||||
|
|
||||||
cp.lock.Lock()
|
cp.lock.Lock()
|
||||||
defer cp.lock.Unlock()
|
defer cp.lock.Unlock()
|
||||||
oldConn := cp.getConn(unique)
|
if oldConn := cp.getConn(unique); oldConn != nil {
|
||||||
if oldConn != nil {
|
|
||||||
// there was a race, oldConn already exists
|
// there was a race, oldConn already exists
|
||||||
ce.destroy()
|
ce.destroy()
|
||||||
return oldConn, unique, nil
|
return oldConn, unique, nil
|
||||||
|
@ -64,8 +64,7 @@ func TestJoinErrors(t *testing.T) {
|
|||||||
assertErrorIs(x, errFoo, false)
|
assertErrorIs(x, errFoo, false)
|
||||||
assertErrorIs(x, errBar, true)
|
assertErrorIs(x, errBar, true)
|
||||||
s1 := "w{w{w{x}}: w{w{foo: bar}}}"
|
s1 := "w{w{w{x}}: w{w{foo: bar}}}"
|
||||||
s2 := w1w2Xw2FooBar.Error()
|
if s2 := w1w2Xw2FooBar.Error(); s1 != s2 {
|
||||||
if s1 != s2 {
|
|
||||||
t.Errorf("%s != %s", s1, s2)
|
t.Errorf("%s != %s", s1, s2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,8 @@ func RoundOffVolSize(size int64) int64 {
|
|||||||
// size less than 1MiB will be round off to 1MiB.
|
// size less than 1MiB will be round off to 1MiB.
|
||||||
func RoundOffBytes(bytes int64) int64 {
|
func RoundOffBytes(bytes int64) int64 {
|
||||||
var num int64
|
var num int64
|
||||||
floatBytes := float64(bytes)
|
|
||||||
// round off the value if its in decimal
|
// 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 = int64(math.Ceil(floatBytes / helpers.MiB))
|
||||||
num *= helpers.MiB
|
num *= helpers.MiB
|
||||||
} else {
|
} else {
|
||||||
@ -142,8 +141,7 @@ func ValidateDriverName(driverName string) error {
|
|||||||
// 'utsname' structs 'release' component.
|
// 'utsname' structs 'release' component.
|
||||||
func GetKernelVersion() (string, error) {
|
func GetKernelVersion() (string, error) {
|
||||||
utsname := unix.Utsname{}
|
utsname := unix.Utsname{}
|
||||||
err := unix.Uname(&utsname)
|
if err := unix.Uname(&utsname); err != nil {
|
||||||
if err != nil {
|
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return strings.TrimRight(string(utsname.Release[:]), "\x00"), nil
|
return strings.TrimRight(string(utsname.Release[:]), "\x00"), nil
|
||||||
|
@ -188,8 +188,7 @@ func initVaultTokensKMS(args KMSInitializerArgs) (EncryptionKMS, error) {
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
config := args.Config
|
config := args.Config
|
||||||
_, ok := config[kmsProviderKey]
|
if _, ok := config[kmsProviderKey]; ok {
|
||||||
if ok {
|
|
||||||
// configuration comes from the ConfigMap, needs to be
|
// configuration comes from the ConfigMap, needs to be
|
||||||
// converted to vaultTokenConf type
|
// converted to vaultTokenConf type
|
||||||
config, err = transformConfig(config)
|
config, err = transformConfig(config)
|
||||||
|
Loading…
Reference in New Issue
Block a user