@@ -34,6 +34,8 @@ import (
3434 "text/template"
3535 "time"
3636
37+ "github.com/pkg/errors"
38+
3739 "github.com/docker/machine/libmachine/drivers"
3840 "github.com/docker/machine/libmachine/log"
3941 "github.com/docker/machine/libmachine/mcnutils"
@@ -125,7 +127,7 @@ func (d *Driver) GetIP() (ip string, err error) {
125127
126128 // attempt to find the address from vmrun
127129 if ip , err := d .getIPfromVmrun (); err == nil {
128- return ip , err
130+ return ip , nil
129131 }
130132
131133 // determine MAC address for VM
@@ -136,7 +138,7 @@ func (d *Driver) GetIP() (ip string, err error) {
136138
137139 // attempt to find the address in the vmnet configuration
138140 if ip , err = d .getIPfromVmnetConfiguration (macaddr ); err == nil {
139- return ip , err
141+ return ip , nil
140142 }
141143
142144 // address not found in vmnet so look for a DHCP lease
@@ -350,7 +352,7 @@ func (d *Driver) Start() error {
350352 }
351353
352354 if ip == "" {
353- return fmt . Errorf ("machine didn't return an IP after 120 seconds, aborting" )
355+ return errors . New ("machine didn't return an IP after 120 seconds, aborting" )
354356 }
355357
356358 // we got an IP
@@ -382,7 +384,7 @@ func (d *Driver) Remove() error {
382384 s , _ := d .GetState ()
383385 if s == state .Running {
384386 if err := d .Kill (); err != nil {
385- return fmt . Errorf ("error stopping VM before deletion" )
387+ return errors . New ("error stopping VM before deletion" )
386388 }
387389 }
388390 log .Infof ("Deleting %s..." , d .MachineName )
@@ -393,7 +395,7 @@ func (d *Driver) Remove() error {
393395}
394396
395397func (d * Driver ) Upgrade () error {
396- return fmt . Errorf ("VMware does not currently support the upgrade operation" )
398+ return errors . New ("VMware does not currently support the upgrade operation" )
397399}
398400
399401func (d * Driver ) vmxPath () string {
@@ -447,7 +449,7 @@ func (d *Driver) getIPfromVmrun() (string, error) {
447449 return match , nil
448450 }
449451
450- return "" , fmt . Errorf ("could not get IP from vmrun" )
452+ return "" , errors . New ("could not get IP from vmrun" )
451453}
452454
453455func (d * Driver ) getIPfromVmnetConfiguration (macaddr string ) (string , error ) {
@@ -457,7 +459,7 @@ func (d *Driver) getIPfromVmnetConfiguration(macaddr string) (string, error) {
457459 for _ , conffile := range confFiles {
458460 log .Debugf ("Trying to find IP address in configuration file: %s" , conffile )
459461 if ipaddr , err := d .getIPfromVmnetConfigurationFile (conffile , macaddr ); err == nil {
460- return ipaddr , err
462+ return ipaddr , nil
461463 }
462464 }
463465
@@ -563,7 +565,7 @@ func (d *Driver) getIPfromDHCPLease(macaddr string) (string, error) {
563565 for _ , dhcpfile := range leasesFiles {
564566 log .Debugf ("Trying to find IP address in leases file: %s" , dhcpfile )
565567 if ipaddr , err := d .getIPfromDHCPLeaseFile (dhcpfile , macaddr ); err == nil {
566- return ipaddr , err
568+ return ipaddr , nil
567569 }
568570 }
569571
@@ -607,7 +609,7 @@ func (d *Driver) getIPfromDHCPLeaseFile(dhcpfile, macaddr string) (string, error
607609 continue
608610 }
609611
610- if matches := leasemac .FindStringSubmatch (line ); matches != nil && matches [1 ] == macaddr && currentleadeendtime .Before (lastleaseendtime ) {
612+ if matches := leasemac .FindStringSubmatch (line ); len ( matches ) > 0 && matches [1 ] == macaddr && currentleadeendtime .Before (lastleaseendtime ) {
611613 currentip = lastipmatch
612614 currentleadeendtime = lastleaseendtime
613615 }
0 commit comments