Skip to content

Commit c47dc45

Browse files
committed
Fix lint issues in the imported drivers
1 parent a9ce903 commit c47dc45

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

pkg/drivers/parallels/parallels.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !darwin
1+
//go:build !darwin
22

33
/*
44
Copyright 2022 The Kubernetes Authors All rights reserved.

pkg/drivers/parallels/parallels_darwin.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ var (
8383
reSharedAdapterIP = regexp.MustCompile(`\s*IPv4 address:\s*(\d+\.\d+\.\d+\.\d+)`)
8484
reSharedFolder = regexp.MustCompile(`\s*(.+) \(\+\) path='(.+)' mode=.+`)
8585

86-
errMachineExist = errors.New("machine already exists")
8786
errMachineNotExist = errors.New("machine does not exist")
8887
errSharedNetworkNotConnected = errors.New("Your Mac host is not connected to Shared network. Please, ensure this option is set: 'Parallels Desktop' -> 'Preferences' -> 'Network' -> 'Shared' -> 'Connect Mac to this network'")
8988

@@ -123,6 +122,8 @@ func NewDriver(hostName, storePath string) drivers.Driver {
123122
}
124123

125124
// Create a host using the driver's config
125+
//
126+
//nolint:gocyclo
126127
func (d *Driver) Create() error {
127128
var (
128129
err error
@@ -157,7 +158,7 @@ func (d *Driver) Create() error {
157158

158159
cpus := d.CPU
159160
if cpus < 1 {
160-
cpus = int(runtime.NumCPU())
161+
cpus = runtime.NumCPU()
161162
}
162163
if cpus > 32 {
163164
cpus = 32
@@ -301,7 +302,7 @@ func (d *Driver) Create() error {
301302

302303
if ip != "" {
303304
log.Debugf("Got an ip: %s", ip)
304-
conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", ip, d.SSHPort), time.Duration(2*time.Second))
305+
conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", ip, d.SSHPort), 2*time.Second)
305306
if err != nil {
306307
log.Debugf("SSH Daemon not responding yet: %s", err)
307308
time.Sleep(2 * time.Second)
@@ -614,6 +615,9 @@ func (d *Driver) getIPfromDHCPLease() (string, error) {
614615
DHCPLeaseFile := "/Library/Preferences/Parallels/parallels_dhcp_leases"
615616

616617
stdout, _, err := prlctlOutErr("list", "-i", d.MachineName)
618+
if err != nil {
619+
return "", err
620+
}
617621
macRe := regexp.MustCompile("net0.* mac=([0-9A-F]{12}) card=.*")
618622
macMatch := macRe.FindAllStringSubmatch(stdout, 1)
619623

@@ -666,7 +670,7 @@ func (d *Driver) getShareFolders() (map[string]string, error) {
666670

667671
// Parse Shared Folder name (ID) and path
668672
res := make(map[string]string)
669-
for _, match := range reSharedFolder.FindAllStringSubmatch(string(stdout), -1) {
673+
for _, match := range reSharedFolder.FindAllStringSubmatch(stdout, -1) {
670674
sName := match[1]
671675
sPath := match[2]
672676
log.Debugf("Found the configured shared folder. Name: %q, Path: %q\n", sName, sPath)
@@ -773,7 +777,7 @@ func getParallelsVersion() (*version.Version, error) {
773777
}
774778

775779
// Parse Parallels Desktop version
776-
verRaw := reParallelsVersion.FindStringSubmatch(string(stdout))
780+
verRaw := reParallelsVersion.FindStringSubmatch(stdout)
777781
if verRaw == nil {
778782
return nil, fmt.Errorf("Parallels Desktop version could not be fetched: %s", stdout)
779783
}
@@ -794,7 +798,7 @@ func getParallelsEdition() (string, error) {
794798
}
795799

796800
// Parse Parallels Desktop version
797-
res := reParallelsEdition.FindStringSubmatch(string(stdout))
801+
res := reParallelsEdition.FindStringSubmatch(stdout)
798802
if res == nil {
799803
return "", fmt.Errorf("Driver \"parallels\" requires Parallels Desktop license to be activated. More info: https://kb.parallels.com/en/124225")
800804
}
@@ -810,7 +814,7 @@ func checkSharedNetworkConnected() error {
810814
}
811815

812816
// Parse the IPv4 of Shared network adapter
813-
res := reSharedAdapterIP.FindStringSubmatch(string(stdout))
817+
res := reSharedAdapterIP.FindStringSubmatch(stdout)
814818
if res == nil {
815819
return errSharedNetworkNotConnected
816820
}
@@ -822,7 +826,7 @@ func checkSharedNetworkConnected() error {
822826
if err != nil {
823827
return err
824828
}
825-
log.Debugf("All host interface addressess: %v", hostAddrs)
829+
log.Debugf("All host interface addresses: %v", hostAddrs)
826830

827831
// Check if the there is an interface with the Shared network adapter's IP assigned
828832
for _, netAddr := range hostAddrs {

pkg/drivers/parallels/prlctl.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build darwin
2+
13
/*
24
Copyright 2022 The Kubernetes Authors All rights reserved.
35
@@ -95,6 +97,7 @@ func prlctlOutErr(args ...string) (string, string, error) {
9597
return runCmd(prlctlCmd, args, errPrlctlNotFound)
9698
}
9799

100+
//nolint:unused
98101
func prlsrvctl(args ...string) error {
99102
_, _, err := runCmd(prlsrvctlCmd, args, errPrlsrvctlNotFound)
100103
return err

0 commit comments

Comments
 (0)