mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2026-02-02 07:35:12 +01:00
chore(go-lint): fix golint warning (#133)
Fixes several go lint cases reported by go report. Signed-off-by: wiwen <shenggxhz@gmail.com>
This commit is contained in:
parent
639ead416e
commit
f5ae3ff476
25 changed files with 78 additions and 51 deletions
|
|
@ -69,6 +69,7 @@ func NewNode(d *CSIDriver) csi.NodeServer {
|
|||
}
|
||||
}
|
||||
|
||||
// GetVolAndMountInfo get volume and mount info from node csi volume request
|
||||
func GetVolAndMountInfo(
|
||||
req *csi.NodePublishVolumeRequest,
|
||||
) (*apis.ZFSVolume, *apis.MountInfo, error) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ import (
|
|||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/openebs/zfs-localpv/pkg/builder/snapbuilder"
|
||||
"github.com/openebs/zfs-localpv/pkg/builder/volbuilder"
|
||||
errors "github.com/openebs/zfs-localpv/pkg/common/errors"
|
||||
|
|
@ -31,9 +35,6 @@ import (
|
|||
csipayload "github.com/openebs/zfs-localpv/pkg/response"
|
||||
analytics "github.com/openebs/zfs-localpv/pkg/usage"
|
||||
zfs "github.com/openebs/zfs-localpv/pkg/zfs"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// controller is the server implementation
|
||||
|
|
@ -74,6 +75,7 @@ func sendEventOrIgnore(pvcName, pvName, capacity, stgType, method string) {
|
|||
}
|
||||
}
|
||||
|
||||
// CreateZFSVolume create new zfs volume from csi volume request
|
||||
func CreateZFSVolume(req *csi.CreateVolumeRequest) (string, error) {
|
||||
volName := req.GetName()
|
||||
size := req.GetCapacityRange().RequiredBytes
|
||||
|
|
@ -137,6 +139,7 @@ func CreateZFSVolume(req *csi.CreateVolumeRequest) (string, error) {
|
|||
return selected, nil
|
||||
}
|
||||
|
||||
// CreateZFSClone create a clone of zfs volume
|
||||
func CreateZFSClone(req *csi.CreateVolumeRequest, snapshot string) (string, error) {
|
||||
|
||||
volName := req.GetName()
|
||||
|
|
@ -260,6 +263,14 @@ func (cs *controller) DeleteVolume(
|
|||
goto deleteResponse
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(
|
||||
err,
|
||||
"failed to get volume for {%s}",
|
||||
volumeID,
|
||||
)
|
||||
}
|
||||
|
||||
// Delete the corresponding ZV CR
|
||||
err = zfs.DeleteVolume(volumeID)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -29,10 +29,9 @@ var supportedAccessMode = &csi.VolumeCapability_AccessMode{
|
|||
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
|
||||
}
|
||||
|
||||
// TODO check if this can be renamed to Base
|
||||
//
|
||||
// CSIDriver defines a common data structure
|
||||
// for drivers
|
||||
// TODO check if this can be renamed to Base
|
||||
type CSIDriver struct {
|
||||
// TODO change the field names to make it
|
||||
// readable
|
||||
|
|
|
|||
|
|
@ -75,22 +75,22 @@ type NonBlockingGRPCServer interface {
|
|||
// NewNonBlockingGRPCServer returns a new instance of NonBlockingGRPCServer
|
||||
func NewNonBlockingGRPCServer(ep string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) NonBlockingGRPCServer {
|
||||
return &nonBlockingGRPCServer{
|
||||
endpoint: ep,
|
||||
idnty_server: ids,
|
||||
ctrl_server: cs,
|
||||
agent_server: ns}
|
||||
endpoint: ep,
|
||||
idntyServer: ids,
|
||||
ctrlServer: cs,
|
||||
agentServer: ns}
|
||||
}
|
||||
|
||||
// NonBlocking server
|
||||
// dont block the execution for a task to complete.
|
||||
// use wait group to wait for all the tasks dispatched.
|
||||
type nonBlockingGRPCServer struct {
|
||||
wg sync.WaitGroup
|
||||
server *grpc.Server
|
||||
endpoint string
|
||||
idnty_server csi.IdentityServer
|
||||
ctrl_server csi.ControllerServer
|
||||
agent_server csi.NodeServer
|
||||
wg sync.WaitGroup
|
||||
server *grpc.Server
|
||||
endpoint string
|
||||
idntyServer csi.IdentityServer
|
||||
ctrlServer csi.ControllerServer
|
||||
agentServer csi.NodeServer
|
||||
}
|
||||
|
||||
// Start grpc server for serving CSI endpoints
|
||||
|
|
@ -98,7 +98,7 @@ func (s *nonBlockingGRPCServer) Start() {
|
|||
|
||||
s.wg.Add(1)
|
||||
|
||||
go s.serve(s.endpoint, s.idnty_server, s.ctrl_server, s.agent_server)
|
||||
go s.serve(s.endpoint, s.idntyServer, s.ctrlServer, s.agentServer)
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue