Fix golint issues

Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
Madhu Rajanna
2019-01-16 18:33:38 +05:30
parent 9ddc265c10
commit 20af5afcab
9 changed files with 42 additions and 42 deletions

View File

@ -433,9 +433,9 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
},
},
}, nil
} else {
return nil, status.Error(codes.NotFound, fmt.Sprintf("Snapshot ID %s cannot found", snapshotID))
}
return nil, status.Error(codes.NotFound, fmt.Sprintf("Snapshot ID %s cannot found", snapshotID))
}
entries := []*csi.ListSnapshotsResponse_Entry{}

View File

@ -61,15 +61,15 @@ func getDevFromImageAndPool(pool, image string) (string, bool) {
// Search /sys/bus for rbd device that matches given pool and image.
func getRbdDevFromImageAndPool(pool string, image string) (string, bool) {
// /sys/bus/rbd/devices/X/name and /sys/bus/rbd/devices/X/pool
sys_path := "/sys/bus/rbd/devices"
if dirs, err := ioutil.ReadDir(sys_path); err == nil {
sysPath := "/sys/bus/rbd/devices"
if dirs, err := ioutil.ReadDir(sysPath); err == nil {
for _, f := range dirs {
// Pool and name format:
// see rbd_pool_show() and rbd_name_show() at
// https://github.com/torvalds/linux/blob/master/drivers/block/rbd.c
name := f.Name()
// First match pool, then match name.
poolFile := path.Join(sys_path, name, "pool")
poolFile := path.Join(sysPath, name, "pool")
poolBytes, err := ioutil.ReadFile(poolFile)
if err != nil {
glog.V(4).Infof("error reading %s: %v", poolFile, err)
@ -79,7 +79,7 @@ func getRbdDevFromImageAndPool(pool string, image string) (string, bool) {
glog.V(4).Infof("device %s is not %q: %q", name, pool, string(poolBytes))
continue
}
imgFile := path.Join(sys_path, name, "name")
imgFile := path.Join(sysPath, name, "name")
imgBytes, err := ioutil.ReadFile(imgFile)
if err != nil {
glog.V(4).Infof("error reading %s: %v", imgFile, err)

View File

@ -104,11 +104,12 @@ func getMon(pOpts *rbdVolume, credentials map[string]string) (string, error) {
// yet another sanity check
return "", fmt.Errorf("either monitors or monValueFromSecret must be set")
}
if val, ok := credentials[pOpts.MonValueFromSecret]; !ok {
val, ok := credentials[pOpts.MonValueFromSecret]
if !ok {
return "", fmt.Errorf("mon data %s is not set in secret", pOpts.MonValueFromSecret)
} else {
mon = val
}
mon = val
}
return mon, nil
}
@ -187,10 +188,9 @@ func rbdStatus(pOpts *rbdVolume, userId string, credentials map[string]string) (
if strings.Contains(output, imageWatcherStr) {
glog.V(4).Infof("rbd: watchers on %s: %s", image, output)
return true, output, nil
} else {
glog.Warningf("rbd: no watchers on %s", image)
return false, output, nil
}
glog.Warningf("rbd: no watchers on %s", image)
return false, output, nil
}
// DeleteImage deletes a ceph image with provision and volume options.
@ -346,11 +346,11 @@ func getSnapMon(pOpts *rbdSnapshot, credentials map[string]string) (string, erro
// yet another sanity check
return "", fmt.Errorf("either monitors or monValueFromSecret must be set")
}
if val, ok := credentials[pOpts.MonValueFromSecret]; !ok {
val, ok := credentials[pOpts.MonValueFromSecret]
if !ok {
return "", fmt.Errorf("mon data %s is not set in secret", pOpts.MonValueFromSecret)
} else {
mon = val
}
mon = val
}
return mon, nil
}