Skip to content

Commit

Permalink
Issue minishift#2541 Fix: Proxy env variable to be cleared upon restart
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenkumar committed Jul 2, 2018
1 parent b7c40f3 commit ebb4366
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions pkg/minikube/cluster/cluster.go
Expand Up @@ -93,6 +93,9 @@ func StartHost(api libmachine.API, config MachineConfig) (*host.Host, error) {
if err := api.Save(h); err != nil {
return nil, fmt.Errorf("Error saving started host: %s", err)
}
if err := setProxyToShell(config, h); err != nil {
return nil, err
}
}

if err := h.ConfigureAuth(); err != nil {
Expand Down Expand Up @@ -347,20 +350,8 @@ func createHost(api libmachine.API, config MachineConfig) (*host.Host, error) {
return nil, fmt.Errorf("Error attempting to save store: %s", err)
}

if config.ShellProxyEnv.IsEnabled() {
fmt.Print("-- Setting proxy information ... ")
vmIP, err := h.Driver.GetIP()
if err != nil {
fmt.Println("FAIL")
return nil, fmt.Errorf("Error getting VM IP: %s", err)
}
config.ShellProxyEnv.AddNoProxy(vmIP)
shellProxyEnv := strings.Join(config.ShellProxyEnv.ProxyConfig(), " ")
if err := minishiftUtil.SetProxyToShellEnv(h, shellProxyEnv); err != nil {
fmt.Println("FAIL")
return nil, fmt.Errorf("Error setting proxy to VM: %s", err)
}
fmt.Println("OK")
if err = setProxyToShell(config, h); err != nil {
return nil, err
}

return h, nil
Expand Down Expand Up @@ -518,3 +509,23 @@ func GetHostIP(api libmachine.API) (string, error) {
}
return ip, nil
}

// setProxyToShell set the proxy details to machine env.
func setProxyToShell(config MachineConfig, h *host.Host) error {
if config.ShellProxyEnv.IsEnabled() {
fmt.Print("-- Setting proxy information ... ")
vmIP, err := h.Driver.GetIP()
if err != nil {
fmt.Println("FAIL")
return fmt.Errorf("Error getting VM IP: %s", err)
}
config.ShellProxyEnv.AddNoProxy(vmIP)
shellProxyEnv := strings.Join(config.ShellProxyEnv.ProxyConfig(), " ")
if err := minishiftUtil.SetProxyToShellEnv(h, shellProxyEnv); err != nil {
fmt.Println("FAIL")
return fmt.Errorf("Error setting proxy to VM: %s", err)
}
fmt.Println("OK")
}
return nil
}

0 comments on commit ebb4366

Please sign in to comment.