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
126127func (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 {
0 commit comments