From 6f53a0b9ed12e9cb13e65ad51b65e784af95401e Mon Sep 17 00:00:00 2001 From: David Gageot Date: Wed, 30 Dec 2015 12:12:06 +0100 Subject: [PATCH] Simpler code Signed-off-by: David Gageot --- libmachine/host/host.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/libmachine/host/host.go b/libmachine/host/host.go index f2778ac0af..0156ba2871 100644 --- a/libmachine/host/host.go +++ b/libmachine/host/host.go @@ -21,8 +21,7 @@ import ( ) var ( - validHostNameChars = `^[a-zA-Z0-9][a-zA-Z0-9\-\.]*$` - validHostNamePattern = regexp.MustCompile(validHostNameChars) + validHostNamePattern = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9\-\.]*$`) errMachineMustBeRunningForUpgrade = errors.New("Error: machine must be running to upgrade.") ) @@ -69,13 +68,9 @@ func (h *Host) CreateSSHClient() (ssh.Client, error) { return ssh.ExternalClient{}, err } - var auth *ssh.Auth - if h.Driver.GetSSHKeyPath() == "" { - auth = &ssh.Auth{} - } else { - auth = &ssh.Auth{ - Keys: []string{h.Driver.GetSSHKeyPath()}, - } + auth := &ssh.Auth{} + if h.Driver.GetSSHKeyPath() != "" { + auth.Keys = []string{h.Driver.GetSSHKeyPath()} } return ssh.NewClient(h.Driver.GetSSHUsername(), addr, port, auth) @@ -181,9 +176,5 @@ func (h *Host) ConfigureAuth() error { // and modularity of the provisioners should be). // // Call provision to re-provision the certs properly. - if err := provisioner.Provision(swarm.Options{}, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions); err != nil { - return err - } - - return nil + return provisioner.Provision(swarm.Options{}, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions) }