Fix lint issues

Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
Madhu Rajanna 2019-01-17 13:04:59 +05:30
parent 5eb1974e38
commit 1d11d0acc3
6 changed files with 22 additions and 22 deletions

View File

@ -96,7 +96,7 @@ func createCephUser(volOptions *volumeOptions, adminCr *credentials, volID volum
"osd", caps.Osd, "osd", caps.Osd,
} }
if err := execCommandJson(&ents, "ceph", args[:]...); err != nil { if err := execCommandJSON(&ents, "ceph", args[:]...); err != nil {
return nil, fmt.Errorf("error creating ceph user: %v", err) return nil, fmt.Errorf("error creating ceph user: %v", err)
} }

View File

@ -65,7 +65,7 @@ func NewNodeServer(d *csicommon.CSIDriver) *nodeServer {
} }
} }
func (fs *driver) Run(driverName, nodeId, endpoint, volumeMounter string, cachePersister util.CachePersister) { func (fs *driver) Run(driverName, nodeID, endpoint, volumeMounter string, cachePersister util.CachePersister) {
glog.Infof("Driver: %v version: %v", driverName, Version) glog.Infof("Driver: %v version: %v", driverName, Version)
// Configuration // Configuration
@ -91,7 +91,7 @@ func (fs *driver) Run(driverName, nodeId, endpoint, volumeMounter string, cacheP
// Initialize default library driver // Initialize default library driver
fs.cd = csicommon.NewCSIDriver(driverName, Version, nodeId) fs.cd = csicommon.NewCSIDriver(driverName, Version, nodeID)
if fs.cd == nil { if fs.cd == nil {
glog.Fatalln("Failed to initialize CSI driver") glog.Fatalln("Failed to initialize CSI driver")
} }

View File

@ -53,7 +53,7 @@ func execCommandAndValidate(program string, args ...string) error {
return nil return nil
} }
func execCommandJson(v interface{}, program string, args ...string) error { func execCommandJSON(v interface{}, program string, args ...string) error {
out, err := execCommand(program, args...) out, err := execCommand(program, args...)
if err != nil { if err != nil {

View File

@ -55,7 +55,7 @@ func loadAvailableMounters() error {
} }
type volumeMounter interface { type volumeMounter interface {
mount(mountPoint string, cr *credentials, volOptions *volumeOptions, volId volumeID) error mount(mountPoint string, cr *credentials, volOptions *volumeOptions, volID volumeID) error
name() string name() string
} }
@ -99,12 +99,12 @@ func newMounter(volOptions *volumeOptions) (volumeMounter, error) {
type fuseMounter struct{} type fuseMounter struct{}
func mountFuse(mountPoint string, cr *credentials, volOptions *volumeOptions, volId volumeID) error { func mountFuse(mountPoint string, cr *credentials, volOptions *volumeOptions, volID volumeID) error {
args := [...]string{ args := [...]string{
mountPoint, mountPoint,
"-c", getCephConfPath(volId), "-c", getCephConfPath(volID),
"-n", cephEntityClientPrefix + cr.id, "-n", cephEntityClientPrefix + cr.id,
"--keyring", getCephKeyringPath(volId, cr.id), "--keyring", getCephKeyringPath(volID, cr.id),
"-r", volOptions.RootPath, "-r", volOptions.RootPath,
"-o", "nonempty", "-o", "nonempty",
} }
@ -121,19 +121,19 @@ func mountFuse(mountPoint string, cr *credentials, volOptions *volumeOptions, vo
return nil return nil
} }
func (m *fuseMounter) mount(mountPoint string, cr *credentials, volOptions *volumeOptions, volId volumeID) error { func (m *fuseMounter) mount(mountPoint string, cr *credentials, volOptions *volumeOptions, volID volumeID) error {
if err := createMountPoint(mountPoint); err != nil { if err := createMountPoint(mountPoint); err != nil {
return err return err
} }
return mountFuse(mountPoint, cr, volOptions, volId) return mountFuse(mountPoint, cr, volOptions, volID)
} }
func (m *fuseMounter) name() string { return "Ceph FUSE driver" } func (m *fuseMounter) name() string { return "Ceph FUSE driver" }
type kernelMounter struct{} type kernelMounter struct{}
func mountKernel(mountPoint string, cr *credentials, volOptions *volumeOptions, volId volumeID) error { func mountKernel(mountPoint string, cr *credentials, volOptions *volumeOptions, volID volumeID) error {
if err := execCommandAndValidate("modprobe", "ceph"); err != nil { if err := execCommandAndValidate("modprobe", "ceph"); err != nil {
return err return err
} }
@ -143,16 +143,16 @@ func mountKernel(mountPoint string, cr *credentials, volOptions *volumeOptions,
fmt.Sprintf("%s:%s", volOptions.Monitors, volOptions.RootPath), fmt.Sprintf("%s:%s", volOptions.Monitors, volOptions.RootPath),
mountPoint, mountPoint,
"-o", "-o",
fmt.Sprintf("name=%s,secretfile=%s", cr.id, getCephSecretPath(volId, cr.id)), fmt.Sprintf("name=%s,secretfile=%s", cr.id, getCephSecretPath(volID, cr.id)),
) )
} }
func (m *kernelMounter) mount(mountPoint string, cr *credentials, volOptions *volumeOptions, volId volumeID) error { func (m *kernelMounter) mount(mountPoint string, cr *credentials, volOptions *volumeOptions, volID volumeID) error {
if err := createMountPoint(mountPoint); err != nil { if err := createMountPoint(mountPoint); err != nil {
return err return err
} }
return mountKernel(mountPoint, cr, volOptions, volId) return mountKernel(mountPoint, cr, volOptions, volID)
} }
func (m *kernelMounter) name() string { return "Ceph kernel client" } func (m *kernelMounter) name() string { return "Ceph kernel client" }

View File

@ -415,7 +415,7 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
return nil, err return nil, err
} }
sourceVolumeId := req.GetSourceVolumeId() sourceVolumeID := req.GetSourceVolumeId()
// TODO (sngchlko) list with token // TODO (sngchlko) list with token
// TODO (#94) protect concurrent access to global data structures // TODO (#94) protect concurrent access to global data structures
@ -424,8 +424,8 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
if snapshotID := req.GetSnapshotId(); len(snapshotID) != 0 { if snapshotID := req.GetSnapshotId(); len(snapshotID) != 0 {
if rbdSnap, ok := rbdSnapshots[snapshotID]; ok { if rbdSnap, ok := rbdSnapshots[snapshotID]; ok {
// if source volume ID also set, check source volume id on the cache. // if source volume ID also set, check source volume id on the cache.
if len(sourceVolumeId) != 0 && rbdSnap.SourceVolumeID != sourceVolumeId { if len(sourceVolumeID) != 0 && rbdSnap.SourceVolumeID != sourceVolumeID {
return nil, status.Errorf(codes.Unknown, "Requested Source Volume ID %s is different from %s", sourceVolumeId, rbdSnap.SourceVolumeID) return nil, status.Errorf(codes.Unknown, "Requested Source Volume ID %s is different from %s", sourceVolumeID, rbdSnap.SourceVolumeID)
} }
return &csi.ListSnapshotsResponse{ return &csi.ListSnapshotsResponse{
Entries: []*csi.ListSnapshotsResponse_Entry{ Entries: []*csi.ListSnapshotsResponse_Entry{
@ -450,7 +450,7 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
entries := []*csi.ListSnapshotsResponse_Entry{} entries := []*csi.ListSnapshotsResponse_Entry{}
for _, rbdSnap := range rbdSnapshots { for _, rbdSnap := range rbdSnapshots {
// if source volume ID also set, check source volume id on the cache. // if source volume ID also set, check source volume id on the cache.
if len(sourceVolumeId) != 0 && rbdSnap.SourceVolumeID != sourceVolumeId { if len(sourceVolumeID) != 0 && rbdSnap.SourceVolumeID != sourceVolumeID {
continue continue
} }
entries = append(entries, &csi.ListSnapshotsResponse_Entry{ entries = append(entries, &csi.ListSnapshotsResponse_Entry{

View File

@ -210,7 +210,7 @@ func checkRbdNbdTools() bool {
return true return true
} }
func attachRBDImage(volOptions *rbdVolume, userId string, credentials map[string]string) (string, error) { func attachRBDImage(volOptions *rbdVolume, userID string, credentials map[string]string) (string, error) {
var err error var err error
var output []byte var output []byte
@ -242,7 +242,7 @@ func attachRBDImage(volOptions *rbdVolume, userId string, credentials map[string
Steps: rbdImageWatcherSteps, Steps: rbdImageWatcherSteps,
} }
err := wait.ExponentialBackoff(backoff, func() (bool, error) { err := wait.ExponentialBackoff(backoff, func() (bool, error) {
used, rbdOutput, err := rbdStatus(volOptions, userId, credentials) used, rbdOutput, err := rbdStatus(volOptions, userID, credentials)
if err != nil { if err != nil {
return false, fmt.Errorf("fail to check rbd image status with: (%v), rbd output: (%s)", err, rbdOutput) return false, fmt.Errorf("fail to check rbd image status with: (%v), rbd output: (%s)", err, rbdOutput)
} }
@ -263,12 +263,12 @@ func attachRBDImage(volOptions *rbdVolume, userId string, credentials map[string
} }
glog.V(5).Infof("rbd: map mon %s", mon) glog.V(5).Infof("rbd: map mon %s", mon)
key, err := getRBDKey(userId, credentials) key, err := getRBDKey(userID, credentials)
if err != nil { if err != nil {
return "", err return "", err
} }
output, err = execCommand(cmdName, []string{ output, err = execCommand(cmdName, []string{
"map", imagePath, "--id", userId, "-m", mon, "--key=" + key}) "map", imagePath, "--id", userID, "-m", mon, "--key=" + key})
if err != nil { if err != nil {
glog.Warningf("rbd: map error %v, rbd output: %s", err, string(output)) glog.Warningf("rbd: map error %v, rbd output: %s", err, string(output))
return "", fmt.Errorf("rbd: map failed %v, rbd output: %s", err, string(output)) return "", fmt.Errorf("rbd: map failed %v, rbd output: %s", err, string(output))