Fixed oversight in VMware builder's mock-driver that neglected to initialize 'HostAddressResult'.
This commit is contained in:
parent
029c357d8c
commit
8cc0776f3a
|
@ -1,6 +1,7 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/helper/multistep"
|
"github.com/hashicorp/packer/helper/multistep"
|
||||||
|
@ -127,13 +128,41 @@ func (d *DriverMock) CommHost(state multistep.StateBag) (string, error) {
|
||||||
return d.CommHostResult, d.CommHostErr
|
return d.CommHostResult, d.CommHostErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MockInterface() net.Interface {
|
||||||
|
interfaces, err := net.Interfaces()
|
||||||
|
|
||||||
|
// Build a dummy interface due to being unable to enumerate interfaces
|
||||||
|
if err != nil || len(interfaces) == 0 {
|
||||||
|
return net.Interface{
|
||||||
|
Index: 0,
|
||||||
|
MTU: -1,
|
||||||
|
Name: "dummy",
|
||||||
|
HardwareAddr: net.HardwareAddr{0, 0, 0, 0, 0, 0},
|
||||||
|
Flags: net.FlagLoopback,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the first loopback interface
|
||||||
|
for _, intf := range interfaces {
|
||||||
|
if intf.Flags&net.FlagLoopback == net.FlagLoopback {
|
||||||
|
return intf
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall-back to just the first one
|
||||||
|
return interfaces[0]
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DriverMock) HostAddress(state multistep.StateBag) (string, error) {
|
func (d *DriverMock) HostAddress(state multistep.StateBag) (string, error) {
|
||||||
|
intf := MockInterface()
|
||||||
|
d.HostAddressResult = intf.HardwareAddr.String()
|
||||||
d.HostAddressCalled = true
|
d.HostAddressCalled = true
|
||||||
d.HostAddressState = state
|
d.HostAddressState = state
|
||||||
return d.HostAddressResult, d.HostAddressErr
|
return d.HostAddressResult, d.HostAddressErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DriverMock) HostIP(state multistep.StateBag) (string, error) {
|
func (d *DriverMock) HostIP(state multistep.StateBag) (string, error) {
|
||||||
|
d.HostIPResult = "127.0.0.1"
|
||||||
d.HostIPCalled = true
|
d.HostIPCalled = true
|
||||||
d.HostIPState = state
|
d.HostIPState = state
|
||||||
return d.HostIPResult, d.HostIPErr
|
return d.HostIPResult, d.HostIPErr
|
||||||
|
|
Loading…
Reference in New Issue