refactor saving IP to node
parent
46fe5c4ac1
commit
da91c6fee1
|
@ -144,8 +144,8 @@ func recreateIfNeeded(api libmachine.API, cc *config.ClusterConfig, n *config.No
|
|||
if err := h.Driver.Start(); err != nil {
|
||||
return h, errors.Wrap(err, "driver start")
|
||||
}
|
||||
if err := api.Save(h); err != nil {
|
||||
return h, errors.Wrap(err, "save")
|
||||
if err := saveHost(api, h, cc, n); err != nil {
|
||||
return h, err
|
||||
}
|
||||
return h, nil
|
||||
}
|
||||
|
|
|
@ -17,12 +17,15 @@ limitations under the License.
|
|||
package machine
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/docker/machine/libmachine"
|
||||
"github.com/docker/machine/libmachine/host"
|
||||
libprovision "github.com/docker/machine/libmachine/provision"
|
||||
"github.com/golang/glog"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/driver"
|
||||
"k8s.io/minikube/pkg/provision"
|
||||
)
|
||||
|
@ -108,3 +111,18 @@ func fastDetectProvisioner(h *host.Host) (libprovision.Provisioner, error) {
|
|||
return provision.NewBuildrootProvisioner(h.Driver), nil
|
||||
}
|
||||
}
|
||||
|
||||
func saveHost(api libmachine.API, h *host.Host, cfg *config.ClusterConfig, n *config.Node) error {
|
||||
if err := api.Save(h); err != nil {
|
||||
return errors.Wrap(err, "save")
|
||||
}
|
||||
|
||||
// Save IP to config file for subsequent use
|
||||
ip, err := h.Driver.GetIP()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n.IP = ip
|
||||
fmt.Printf("SAVING NEW IP HERE: %s\n", ip)
|
||||
return config.SaveNode(cfg, n)
|
||||
}
|
||||
|
|
|
@ -148,18 +148,7 @@ func createHost(api libmachine.API, cfg *config.ClusterConfig, n *config.Node) (
|
|||
return h, errors.Wrap(err, "post-start")
|
||||
}
|
||||
|
||||
if err := api.Save(h); err != nil {
|
||||
return nil, errors.Wrap(err, "save")
|
||||
}
|
||||
|
||||
// Save IP to config file for subsequent use
|
||||
ip, err := h.Driver.GetIP()
|
||||
if err != nil {
|
||||
return h, err
|
||||
}
|
||||
n.IP = ip
|
||||
err = config.SaveNode(cfg, n)
|
||||
if err != nil {
|
||||
if err := saveHost(api, h, cfg, n); err != nil {
|
||||
return h, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue