refact(pkg): Removes unused import, variables and functions. (#321)

Signed-off-by: Rahul Grover <rahulgrover99@gmail.com>
This commit is contained in:
Rahul Grover 2021-05-04 19:57:41 +05:30 committed by GitHub
parent 0e6a02ea74
commit a8376796b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 36 deletions

View file

@ -382,7 +382,7 @@ func (ns *node) NodeGetVolumeStats(
return nil, status.Error(codes.InvalidArgument, "path is not provided")
}
if mount.IsMountPath(path) == false {
if !mount.IsMountPath(path) {
return nil, status.Error(codes.NotFound, "path is not a mount path")
}

View file

@ -66,7 +66,7 @@ func NewController(d *CSIDriver) csi.ControllerServer {
// SupportedVolumeCapabilityAccessModes contains the list of supported access
// modes for the volume
var SupportedVolumeCapabilityAccessModes = []*csi.VolumeCapability_AccessMode{
&csi.VolumeCapability_AccessMode{
{
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
}
@ -102,7 +102,7 @@ func getRoundedCapacity(size int64) int64 {
}
func waitForVolDestroy(volname string) error {
for true {
for {
_, err := zfs.GetZFSVolume(volname)
if err != nil {
if k8serror.IsNotFound(err) {
@ -114,11 +114,10 @@ func waitForVolDestroy(volname string) error {
time.Sleep(time.Second)
klog.Infof("waiting for volume to be destroyed %s", volname)
}
return nil
}
func waitForReadySnapshot(snapname string) error {
for true {
for {
snap, err := zfs.GetZFSSnapshot(snapname)
if err != nil {
return status.Errorf(codes.Internal,
@ -131,7 +130,6 @@ func waitForReadySnapshot(snapname string) error {
}
time.Sleep(time.Second)
}
return nil
}
// CreateZFSVolume create new zfs volume from csi volume request
@ -802,18 +800,6 @@ func (cs *controller) ListVolumes(
return nil, status.Error(codes.Unimplemented, "")
}
// validateCapabilities validates if provided capabilities
// are supported by this driver
func validateCapabilities(caps []*csi.VolumeCapability) bool {
for _, cap := range caps {
if !IsSupportedVolumeCapabilityAccessMode(cap.AccessMode.Mode) {
return false
}
}
return true
}
func (cs *controller) validateDeleteVolumeReq(req *csi.DeleteVolumeRequest) error {
volumeID := req.GetVolumeId()
if volumeID == "" {

View file

@ -22,13 +22,6 @@ import (
"k8s.io/klog"
)
// volume can only be published once as
// read/write on a single node, at any
// given time
var supportedAccessMode = &csi.VolumeCapability_AccessMode{
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
}
// CSIDriver defines a common data structure
// for drivers
// TODO check if this can be renamed to Base

View file

@ -41,7 +41,7 @@ func parseEndpoint(ep string) (string, string, error) {
return s[0], s[1], nil
}
}
return "", "", fmt.Errorf("Invalid endpoint: %v", ep)
return "", "", fmt.Errorf("invalid endpoint: %v", ep)
}
//filters if the logd are informative or pollutant
@ -68,13 +68,13 @@ func isInfotrmativeLog(info string) bool {
func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
log := isInfotrmativeLog(info.FullMethod)
if log == true {
if log {
klog.Infof("GRPC call: %s requests %s", info.FullMethod, protosanitizer.StripSecrets(req))
}
resp, err := handler(ctx, req)
if log == true {
if log {
if err != nil {
klog.Errorf("GRPC error: %v", err)
} else {
@ -127,7 +127,6 @@ func (s *nonBlockingGRPCServer) Start() {
go s.serve(s.endpoint, s.idntyServer, s.ctrlServer, s.agentServer)
return
}
// Wait for the service to stop

View file

@ -28,7 +28,6 @@ import (
"github.com/openebs/zfs-localpv/pkg/builder/snapbuilder"
"github.com/openebs/zfs-localpv/pkg/builder/volbuilder"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog"
)
@ -225,7 +224,7 @@ func DeleteVolume(volumeID string) (err error) {
// GetVolList fetches the current Published Volume list
func GetVolList(volumeID string) (*apis.ZFSVolumeList, error) {
listOptions := v1.ListOptions{
listOptions := metav1.ListOptions{
LabelSelector: ZFSNodeKey + "=" + NodeID,
}

View file

@ -457,8 +457,7 @@ func CreateClone(vol *apis.ZFSVolume) error {
}
if err := getVolume(volume); err != nil {
var args []string
args = buildCloneCreateArgs(vol)
args := buildCloneCreateArgs(vol)
cmd := exec.Command(ZFSVolCmd, args...)
out, err := cmd.CombinedOutput()
@ -749,7 +748,7 @@ func ResizeZFSVolume(vol *apis.ZFSVolume, mountpath string, resizefs bool) error
return err
}
if resizefs == true {
if resizefs {
// resize the filesystem so that applications can use the expanded space
err = handleVolResize(vol, mountpath)
}