提交 23fa28f7 编写于 作者: T Thomas Stromberg

Add HostIP support for none, reduce tech debt

上级 b50e816d
......@@ -106,7 +106,7 @@ var mountCmd = &cobra.Command{
var ip net.IP
var err error
if mountIP == "" {
ip, err = cluster.GetVMHostIP(co.CP.Host)
ip, err = cluster.HostIP(co.CP.Host)
if err != nil {
exit.WithError("Error getting the host IP address to use from within the VM", err)
}
......
......@@ -188,7 +188,7 @@ func status(api libmachine.API, cc config.ClusterConfig, n config.Node) (*Status
}
// We have a fully operational host, now we can check for details
if _, err := cluster.GetHostDriverIP(api, name); err != nil {
if _, err := cluster.DriverIP(api, name); err != nil {
glog.Errorf("failed to get driver ip: %v", err)
st.Host = state.Error.String()
return st, err
......
......@@ -30,8 +30,8 @@ import (
"k8s.io/minikube/pkg/minikube/machine"
)
// GetVMHostIP gets the ip address to be used for mapping host -> VM and VM -> host
func GetVMHostIP(host *host.Host) (net.IP, error) {
// HostIP gets the ip address to be used for mapping host -> VM and VM -> host
func HostIP(host *host.Host) (net.IP, error) {
switch host.DriverName {
case driver.Docker:
return oci.RoutableHostIPFromInside(oci.Docker, host.Name)
......@@ -72,13 +72,15 @@ func GetVMHostIP(host *host.Host) (net.IP, error) {
return []byte{}, errors.Wrap(err, "Error converting VM IP address to IPv4 address")
}
return net.IPv4(vmIP[0], vmIP[1], vmIP[2], byte(1)), nil
case driver.None:
return net.ParseIP("127.0.0.1"), nil
default:
return []byte{}, errors.New("Error, attempted to get host ip address for unsupported driver")
return []byte{}, fmt.Errorf("HostIP not yet implemented for %q driver", host.DriverName)
}
}
// GetHostDriverIP gets the ip address of the current minikube cluster
func GetHostDriverIP(api libmachine.API, machineName string) (net.IP, error) {
// DriverIP gets the ip address of the current minikube cluster
func DriverIP(api libmachine.API, machineName string) (net.IP, error) {
host, err := machine.LoadHost(api, machineName)
if err != nil {
return nil, err
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册