Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(import): align alias naming with convention used in other repos #145

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/cmd/dmsetup/dmsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"github.com/sirupsen/logrus"
"github.com/urfave/cli"

commonTypes "github.com/longhorn/go-common-libs/types"
commontypes "github.com/longhorn/go-common-libs/types"
"github.com/longhorn/go-spdk-helper/pkg/util"
)

Expand All @@ -16,8 +16,8 @@
Flags: []cli.Flag{
cli.StringFlag{
Name: "host-proc",
Usage: fmt.Sprintf("The host proc path of namespace executor. By default %v", commonTypes.ProcDirectory),
Value: commonTypes.ProcDirectory,
Usage: fmt.Sprintf("The host proc path of namespace executor. By default %v", commontypes.ProcDirectory),
Value: commontypes.ProcDirectory,

Check warning on line 20 in app/cmd/dmsetup/dmsetup.go

View check run for this annotation

Codecov / codecov/patch

app/cmd/dmsetup/dmsetup.go#L19-L20

Added lines #L19 - L20 were not covered by tests
},
},
Subcommands: []cli.Command{
Expand Down
6 changes: 3 additions & 3 deletions app/cmd/nvmecli/nvmecli.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"github.com/sirupsen/logrus"
"github.com/urfave/cli"

commonTypes "github.com/longhorn/go-common-libs/types"
commontypes "github.com/longhorn/go-common-libs/types"

"github.com/longhorn/go-spdk-helper/pkg/nvme"
"github.com/longhorn/go-spdk-helper/pkg/types"
Expand All @@ -19,8 +19,8 @@
Flags: []cli.Flag{
cli.StringFlag{
Name: "host-proc",
Usage: fmt.Sprintf("The host proc path of namespace executor. By default %v", commonTypes.ProcDirectory),
Value: commonTypes.ProcDirectory,
Usage: fmt.Sprintf("The host proc path of namespace executor. By default %v", commontypes.ProcDirectory),
Value: commontypes.ProcDirectory,

Check warning on line 23 in app/cmd/nvmecli/nvmecli.go

View check run for this annotation

Codecov / codecov/patch

app/cmd/nvmecli/nvmecli.go#L22-L23

Added lines #L22 - L23 were not covered by tests
},
},
Subcommands: []cli.Command{
Expand Down
6 changes: 3 additions & 3 deletions app/cmd/spdksetup/spdksetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"github.com/sirupsen/logrus"
"github.com/urfave/cli"

commonTypes "github.com/longhorn/go-common-libs/types"
commontypes "github.com/longhorn/go-common-libs/types"
spdksetup "github.com/longhorn/go-spdk-helper/pkg/spdk/setup"
"github.com/longhorn/go-spdk-helper/pkg/util"
)
Expand All @@ -19,8 +19,8 @@
Flags: []cli.Flag{
cli.StringFlag{
Name: "host-proc",
Usage: fmt.Sprintf("The host proc path of namespace executor. By default %v", commonTypes.ProcDirectory),
Value: commonTypes.ProcDirectory,
Usage: fmt.Sprintf("The host proc path of namespace executor. By default %v", commontypes.ProcDirectory),
Value: commontypes.ProcDirectory,

Check warning on line 23 in app/cmd/spdksetup/spdksetup.go

View check run for this annotation

Codecov / codecov/patch

app/cmd/spdksetup/spdksetup.go#L22-L23

Added lines #L22 - L23 were not covered by tests
},
},
Subcommands: []cli.Command{
Expand Down
4 changes: 2 additions & 2 deletions app/cmd/spdktgt/spdktgt.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"github.com/sirupsen/logrus"
"github.com/urfave/cli"

commonTypes "github.com/longhorn/go-common-libs/types"
commontypes "github.com/longhorn/go-common-libs/types"

"github.com/longhorn/go-spdk-helper/pkg/spdk/target"
"github.com/longhorn/go-spdk-helper/pkg/util"
Expand Down Expand Up @@ -44,7 +44,7 @@
}

func spdkTGT(c *cli.Context) error {
ne, err := util.NewExecutor(commonTypes.ProcDirectory)
ne, err := util.NewExecutor(commontypes.ProcDirectory)

Check warning on line 47 in app/cmd/spdktgt/spdktgt.go

View check run for this annotation

Codecov / codecov/patch

app/cmd/spdktgt/spdktgt.go#L47

Added line #L47 was not covered by tests
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/nvme/initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

commonNs "github.com/longhorn/go-common-libs/ns"
commonTypes "github.com/longhorn/go-common-libs/types"
commonns "github.com/longhorn/go-common-libs/ns"
commontypes "github.com/longhorn/go-common-libs/types"
"github.com/longhorn/nsfilelock"

"github.com/longhorn/go-spdk-helper/pkg/types"
Expand Down Expand Up @@ -47,7 +47,7 @@ type Initiator struct {
isUp bool

hostProc string
executor *commonNs.Executor
executor *commonns.Executor

logger logrus.FieldLogger
}
Expand All @@ -59,7 +59,7 @@ func NewInitiator(name, subsystemNQN, hostProc string) (*Initiator, error) {
}

// If transportAddress or transportServiceID is empty, the initiator is still valid for stopping
executor, err := util.NewExecutor(commonTypes.ProcDirectory)
executor, err := util.NewExecutor(commontypes.ProcDirectory)
if err != nil {
return nil, err
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/nvme/nvme.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

commonNs "github.com/longhorn/go-common-libs/ns"
commonns "github.com/longhorn/go-common-libs/ns"
)

const (
ErrorMessageCannotFindValidNvmeDevice = "cannot find a valid nvme device"
)

// DiscoverTarget discovers a target
func DiscoverTarget(ip, port string, executor *commonNs.Executor) (subnqn string, err error) {
func DiscoverTarget(ip, port string, executor *commonns.Executor) (subnqn string, err error) {
hostID, err := getHostID(executor)
if err != nil {
return "", err
Expand All @@ -40,7 +40,7 @@
}

// ConnectTarget connects to a target
func ConnectTarget(ip, port, nqn string, executor *commonNs.Executor) (controllerName string, err error) {
func ConnectTarget(ip, port, nqn string, executor *commonns.Executor) (controllerName string, err error) {
// Trying to connect an existing subsystem will error out with exit code 114.
// Hence, it's better to check the existence first.
if devices, err := GetDevices(ip, port, nqn, executor); err == nil && len(devices) > 0 {
Expand All @@ -60,12 +60,12 @@
}

// DisconnectTarget disconnects a target
func DisconnectTarget(nqn string, executor *commonNs.Executor) error {
func DisconnectTarget(nqn string, executor *commonns.Executor) error {
return disconnect(nqn, executor)
}

// GetDevices returns all devices
func GetDevices(ip, port, nqn string, executor *commonNs.Executor) (devices []Device, err error) {
func GetDevices(ip, port, nqn string, executor *commonns.Executor) (devices []Device, err error) {
defer func() {
err = errors.Wrapf(err, "failed to get devices for address %s:%s and nqn %s", ip, port, nqn)
}()
Expand Down Expand Up @@ -172,11 +172,11 @@
}

// GetSubsystems returns all devices
func GetSubsystems(executor *commonNs.Executor) (subsystems []Subsystem, err error) {
func GetSubsystems(executor *commonns.Executor) (subsystems []Subsystem, err error) {

Check warning on line 175 in pkg/nvme/nvme.go

View check run for this annotation

Codecov / codecov/patch

pkg/nvme/nvme.go#L175

Added line #L175 was not covered by tests
return listSubsystems("", executor)
}

// Flush commits data and metadata associated with the specified namespace(s) to nonvolatile media.
func Flush(device, namespaceID string, executor *commonNs.Executor) (output string, err error) {
func Flush(device, namespaceID string, executor *commonns.Executor) (output string, err error) {

Check warning on line 180 in pkg/nvme/nvme.go

View check run for this annotation

Codecov / codecov/patch

pkg/nvme/nvme.go#L180

Added line #L180 was not covered by tests
return flush(device, namespaceID, executor)
}
24 changes: 12 additions & 12 deletions pkg/nvme/nvmecli.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"strconv"
"strings"

commonNs "github.com/longhorn/go-common-libs/ns"
commonns "github.com/longhorn/go-common-libs/ns"

"github.com/longhorn/go-spdk-helper/pkg/types"
)
Expand Down Expand Up @@ -67,7 +67,7 @@
State string `json:"State,omitempty"`
}

func cliVersion(executor *commonNs.Executor) (major, minor int, err error) {
func cliVersion(executor *commonns.Executor) (major, minor int, err error) {
opts := []string{
"--version",
}
Expand Down Expand Up @@ -105,7 +105,7 @@
return major, minor, nil
}

func showHostNQN(executor *commonNs.Executor) (string, error) {
func showHostNQN(executor *commonns.Executor) (string, error) {
opts := []string{
"--show-hostnqn",
}
Expand All @@ -124,7 +124,7 @@
return "", fmt.Errorf("failed to get host NQN from %s", outputStr)
}

func listSubsystems(devicePath string, executor *commonNs.Executor) ([]Subsystem, error) {
func listSubsystems(devicePath string, executor *commonns.Executor) ([]Subsystem, error) {
major, _, err := cliVersion(executor)
if err != nil {
return nil, err
Expand Down Expand Up @@ -154,7 +154,7 @@
return listSubsystemsV2(jsonStr, executor)
}

func listSubsystemsV1(jsonStr string, executor *commonNs.Executor) ([]Subsystem, error) {
func listSubsystemsV1(jsonStr string, executor *commonns.Executor) ([]Subsystem, error) {

Check warning on line 157 in pkg/nvme/nvmecli.go

View check run for this annotation

Codecov / codecov/patch

pkg/nvme/nvmecli.go#L157

Added line #L157 was not covered by tests
output := map[string][]Subsystem{}
if err := json.Unmarshal([]byte(jsonStr), &output); err != nil {
return nil, err
Expand All @@ -169,7 +169,7 @@
Subsystems []Subsystem `json:"Subsystems"`
}

func listSubsystemsV2(jsonStr string, executor *commonNs.Executor) ([]Subsystem, error) {
func listSubsystemsV2(jsonStr string, executor *commonns.Executor) ([]Subsystem, error) {
var output []ListSubsystemsV2Output
if err := json.Unmarshal([]byte(jsonStr), &output); err != nil {
return nil, err
Expand Down Expand Up @@ -197,7 +197,7 @@
SectorSize int32 `json:"SectorSize,omitempty"`
}

func listControllers(executor *commonNs.Executor) ([]CliDevice, error) {
func listControllers(executor *commonns.Executor) ([]CliDevice, error) {
opts := []string{
"list",
"-o", "json",
Expand All @@ -218,7 +218,7 @@
return output["Devices"], nil
}

func getHostID(executor *commonNs.Executor) (string, error) {
func getHostID(executor *commonns.Executor) (string, error) {
outputStr, err := executor.Execute(nil, "cat", []string{"/etc/nvme/hostid"}, types.ExecuteTimeout)
if err == nil {
return strings.TrimSpace(string(outputStr)), nil
Expand All @@ -232,7 +232,7 @@
return "", err
}

func discovery(hostID, hostNQN, ip, port string, executor *commonNs.Executor) ([]DiscoveryPageEntry, error) {
func discovery(hostID, hostNQN, ip, port string, executor *commonns.Executor) ([]DiscoveryPageEntry, error) {
opts := []string{
"discover",
"-t", DefaultTransportType,
Expand Down Expand Up @@ -301,7 +301,7 @@
return output.Entries, nil
}

func connect(hostID, hostNQN, nqn, transpotType, ip, port string, executor *commonNs.Executor) (string, error) {
func connect(hostID, hostNQN, nqn, transpotType, ip, port string, executor *commonns.Executor) (string, error) {
var err error

opts := []string{
Expand Down Expand Up @@ -349,7 +349,7 @@
return output["device"], nil
}

func disconnect(nqn string, executor *commonNs.Executor) error {
func disconnect(nqn string, executor *commonns.Executor) error {
opts := []string{
"disconnect",
"--nqn", nqn,
Expand Down Expand Up @@ -414,7 +414,7 @@
return traddr, trsvcid
}

func flush(devicePath, namespaceID string, executor *commonNs.Executor) (string, error) {
func flush(devicePath, namespaceID string, executor *commonns.Executor) (string, error) {

Check warning on line 417 in pkg/nvme/nvmecli.go

View check run for this annotation

Codecov / codecov/patch

pkg/nvme/nvmecli.go#L417

Added line #L417 was not covered by tests

opts := []string{
"flush",
Expand Down
10 changes: 5 additions & 5 deletions pkg/spdk/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

"github.com/pkg/errors"

commonNs "github.com/longhorn/go-common-libs/ns"
commonns "github.com/longhorn/go-common-libs/ns"

"github.com/longhorn/go-spdk-helper/pkg/types"
)
Expand All @@ -16,7 +16,7 @@
spdkSetupPath = "/usr/src/spdk/scripts/setup.sh"
)

func Bind(deviceAddr, deviceDriver string, executor *commonNs.Executor) (string, error) {
func Bind(deviceAddr, deviceDriver string, executor *commonns.Executor) (string, error) {

Check warning on line 19 in pkg/spdk/setup/setup.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/setup/setup.go#L19

Added line #L19 was not covered by tests
if deviceAddr == "" {
return "", fmt.Errorf("device address is empty")
}
Expand All @@ -40,7 +40,7 @@
return outputStr, nil
}

func Unbind(deviceAddr string, executor *commonNs.Executor) (string, error) {
func Unbind(deviceAddr string, executor *commonns.Executor) (string, error) {

Check warning on line 43 in pkg/spdk/setup/setup.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/setup/setup.go#L43

Added line #L43 was not covered by tests
if deviceAddr == "" {
return "", fmt.Errorf("device address is empty")
}
Expand All @@ -59,7 +59,7 @@
return outputStr, nil
}

func GetDiskDriver(deviceAddr string, executor *commonNs.Executor) (string, error) {
func GetDiskDriver(deviceAddr string, executor *commonns.Executor) (string, error) {

Check warning on line 62 in pkg/spdk/setup/setup.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/setup/setup.go#L62

Added line #L62 was not covered by tests
if deviceAddr == "" {
return "", fmt.Errorf("device address is empty")
}
Expand All @@ -78,7 +78,7 @@
return extractJSON(outputStr)
}

func GetDiskStatus(deviceAddr string, executor *commonNs.Executor) (*types.DiskStatus, error) {
func GetDiskStatus(deviceAddr string, executor *commonns.Executor) (*types.DiskStatus, error) {

Check warning on line 81 in pkg/spdk/setup/setup.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/setup/setup.go#L81

Added line #L81 was not covered by tests
if deviceAddr == "" {
return nil, fmt.Errorf("device address is empty")
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/spdk/spdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

. "gopkg.in/check.v1"

commonTypes "github.com/longhorn/go-common-libs/types"
commontypes "github.com/longhorn/go-common-libs/types"

"github.com/longhorn/go-spdk-helper/pkg/jsonrpc"
"github.com/longhorn/go-spdk-helper/pkg/nvme"
Expand Down Expand Up @@ -91,7 +91,7 @@ func PrepareDeviceFile(c *C) {
func (s *TestSuite) TestSPDKTargetWithHostNamespace(c *C) {
fmt.Println("Testing SPDK Target With Host Namespace")

ne, err := util.NewExecutor(commonTypes.HostProcDirectory)
ne, err := util.NewExecutor(commontypes.HostProcDirectory)
c.Assert(err, IsNil)

LaunchTestSPDKTarget(c, ne.Execute)
Expand All @@ -100,7 +100,7 @@ func (s *TestSuite) TestSPDKTargetWithHostNamespace(c *C) {
func (s *TestSuite) TestSPDKBasic(c *C) {
fmt.Println("Testing SPDK Basic")

ne, err := util.NewExecutor(commonTypes.ProcDirectory)
ne, err := util.NewExecutor(commontypes.ProcDirectory)
c.Assert(err, IsNil)

LaunchTestSPDKTarget(c, ne.Execute)
Expand Down Expand Up @@ -346,7 +346,7 @@ func (s *TestSuite) TestSPDKBasic(c *C) {

// Use Linux nvme driver to attach to our RAID1 exported via NVMe-oF and create a filesystem on it
// The creation of a filesystem will write some data on the lvol
executor, err := util.NewExecutor(commonTypes.ProcDirectory)
executor, err := util.NewExecutor(commontypes.ProcDirectory)
c.Assert(err, IsNil)
_, err = executor.Execute(nil, "ls", []string{"/dev/longhorn/"}, types.ExecuteTimeout)
c.Assert(err, IsNil)
Expand Down Expand Up @@ -387,7 +387,7 @@ func (s *TestSuite) TestSPDKBasic(c *C) {
func (s *TestSuite) TestSPDKClientMultiThread(c *C) {
fmt.Println("Testing SPDK Client Multi Thread")

ne, err := util.NewExecutor(commonTypes.ProcDirectory)
ne, err := util.NewExecutor(commontypes.ProcDirectory)
c.Assert(err, IsNil)

LaunchTestSPDKTarget(c, ne.Execute)
Expand Down Expand Up @@ -474,7 +474,7 @@ func (s *TestSuite) TestSPDKClientMultiThread(c *C) {
func (s *TestSuite) TestSPDKEngineSuspend(c *C) {
fmt.Println("Testing Engine Suspend")

ne, err := util.NewExecutor(commonTypes.ProcDirectory)
ne, err := util.NewExecutor(commontypes.ProcDirectory)
c.Assert(err, IsNil)

LaunchTestSPDKTarget(c, ne.Execute)
Expand Down
Loading
Loading