From cba15e843f60446715055489ee04de65a5a01e02 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Fri, 17 Apr 2015 09:04:19 -0400 Subject: [PATCH 1/9] powershell support Signed-off-by: Evan Hazlett --- commands/commands.go | 4 ++++ commands/env.go | 14 +++++++++++++- ssh/keys.go | 5 ++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/commands/commands.go b/commands/commands.go index 1efb9daac1..568afcc546 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -228,6 +228,10 @@ var Commands = []cli.Command{ Name: "swarm", Usage: "Display the Swarm config instead of the Docker daemon", }, + cli.StringFlag{ + Name: "shell", + Usage: "Force environment to be configured for specified shell", + }, cli.BoolFlag{ Name: "unset, u", Usage: "Unset variables instead of setting them", diff --git a/commands/env.go b/commands/env.go index 2e688be2db..e751a13a50 100644 --- a/commands/env.go +++ b/commands/env.go @@ -14,7 +14,10 @@ import ( ) func cmdEnv(c *cli.Context) { - userShell := filepath.Base(os.Getenv("SHELL")) + userShell := c.String("shell") + if userShell == "" { + userShell = filepath.Base(os.Getenv("SHELL")) + } if c.Bool("unset") { switch userShell { case "fish": @@ -89,6 +92,9 @@ func cmdEnv(c *cli.Context) { case "fish": fmt.Printf("set -x DOCKER_TLS_VERIFY 1;\nset -x DOCKER_CERT_PATH %q;\nset -x DOCKER_HOST %s;\n\n%s\n", cfg.machineDir, dockerHost, usageHint) + case "powershell": + fmt.Printf("$env:DOCKER_TLS_VERIFY=1\n$env:DOCKER_CERT_PATH=\"%s\"\n$env:DOCKER_HOST=\"%s\"\n\n%s\n", + cfg.machineDir, dockerHost, usageHint) default: fmt.Printf("export DOCKER_TLS_VERIFY=1\nexport DOCKER_CERT_PATH=%q\nexport DOCKER_HOST=%s\n\n%s\n", cfg.machineDir, dockerHost, usageHint) @@ -98,6 +104,12 @@ func cmdEnv(c *cli.Context) { func generateUsageHint(machineName string, userShell string) string { cmd := "" switch userShell { + case "powershell": + if machineName != "" { + cmd = fmt.Sprintf("Param(docker-machine env %s)", machineName) + } else { + cmd = "Param(docker-machine env)" + } case "fish": if machineName != "" { cmd = fmt.Sprintf("eval (docker-machine env %s)", machineName) diff --git a/ssh/keys.go b/ssh/keys.go index 636a684b4b..ce815fcbce 100644 --- a/ssh/keys.go +++ b/ssh/keys.go @@ -12,6 +12,7 @@ import ( "io" "os" "runtime" + "syscall" gossh "golang.org/x/crypto/ssh" ) @@ -82,7 +83,9 @@ func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) erro // windows does not support chmod switch runtime.GOOS { - case "darwin", "linux": + case "windows": + syscall.Chmod(f.Name(), 0600) + default: if err := f.Chmod(0600); err != nil { return err } From 758568066878da820e53ebbe048544ebc9467e61 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Fri, 17 Apr 2015 13:51:13 -0400 Subject: [PATCH 2/9] add export and clear env for powershell Signed-off-by: Evan Hazlett --- commands/env.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/env.go b/commands/env.go index e751a13a50..90ed78aaa4 100644 --- a/commands/env.go +++ b/commands/env.go @@ -22,6 +22,8 @@ func cmdEnv(c *cli.Context) { switch userShell { case "fish": fmt.Printf("set -e DOCKER_TLS_VERIFY;\nset -e DOCKER_CERT_PATH;\nset -e DOCKER_HOST;\n") + case "powershell": + fmt.Printf("Remove-Item Env:\\DOCKER_TLS_VERIFY\nRemove-Item Env:\\DOCKER_CERT_PATH\nRemove-Item Env:\\DOCKER_HOST\n") default: fmt.Println("unset DOCKER_TLS_VERIFY DOCKER_CERT_PATH DOCKER_HOST") } @@ -93,8 +95,8 @@ func cmdEnv(c *cli.Context) { fmt.Printf("set -x DOCKER_TLS_VERIFY 1;\nset -x DOCKER_CERT_PATH %q;\nset -x DOCKER_HOST %s;\n\n%s\n", cfg.machineDir, dockerHost, usageHint) case "powershell": - fmt.Printf("$env:DOCKER_TLS_VERIFY=1\n$env:DOCKER_CERT_PATH=\"%s\"\n$env:DOCKER_HOST=\"%s\"\n\n%s\n", - cfg.machineDir, dockerHost, usageHint) + fmt.Printf("$Env:DOCKER_TLS_VERIFY = 1\n$Env:DOCKER_CERT_PATH = \"%s\"\n$Env:DOCKER_HOST = \"%s\"\n", + cfg.machineDir, dockerHost) default: fmt.Printf("export DOCKER_TLS_VERIFY=1\nexport DOCKER_CERT_PATH=%q\nexport DOCKER_HOST=%s\n\n%s\n", cfg.machineDir, dockerHost, usageHint) From e13e2b61c6e9a80c3e04815570b48be06ea0b344 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Mon, 20 Apr 2015 16:34:19 -0400 Subject: [PATCH 3/9] use template for shell config; more powershell and cmd fixes Signed-off-by: Evan Hazlett --- commands/commands.go | 21 ++++++++ commands/env.go | 112 ++++++++++++++++++++++++++++++++++++------- ssh/keys.go | 5 +- 3 files changed, 116 insertions(+), 22 deletions(-) diff --git a/commands/commands.go b/commands/commands.go index 568afcc546..20536caa65 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -1,6 +1,7 @@ package commands import ( + "errors" "fmt" "os" "path/filepath" @@ -33,6 +34,10 @@ import ( "github.com/docker/machine/utils" ) +var ( + ErrUnknownShell = errors.New("unknown shell") +) + type machineConfig struct { machineName string machineDir string @@ -648,3 +653,19 @@ func getCertPathInfo(c *cli.Context) libmachine.CertPathInfo { ClientKeyPath: clientKeyPath, } } + +func detectShell() (string, error) { + // attempt to get the SHELL env var + shell := filepath.Base(os.Getenv("SHELL")) + // none detected; check for windows env + if shell == "." && os.Getenv("windir") != "" { + log.Printf("On Windows, please specify either cmd or powershell with the --shell flag.\n\n") + return "", ErrUnknownShell + } + + if shell == "" { + return "", ErrUnknownShell + } + + return shell, nil +} diff --git a/commands/env.go b/commands/env.go index 90ed78aaa4..3e5e8b4df6 100644 --- a/commands/env.go +++ b/commands/env.go @@ -4,8 +4,8 @@ import ( "fmt" "net/url" "os" - "path/filepath" "strings" + "text/template" log "github.com/Sirupsen/logrus" @@ -13,19 +13,72 @@ import ( "github.com/docker/machine/utils" ) +const ( + envTmpl = `{{ .Prefix }}DOCKER_TLS_VERIFY{{ .Delimiter }}{{ .DockerTLSVerify }}{{ .Suffix }}{{ .Prefix }}DOCKER_HOST{{ .Delimiter }}{{ .DockerHost }}{{ .Suffix }}{{ .Prefix }}DOCKER_CERT_PATH{{ .Delimiter }}{{ .DockerCertPath }}{{ .Suffix }}{{ .UsageHint }}` +) + +type ShellConfig struct { + Prefix string + Delimiter string + Suffix string + DockerCertPath string + DockerHost string + DockerTLSVerify string + UsageHint string +} + func cmdEnv(c *cli.Context) { userShell := c.String("shell") if userShell == "" { - userShell = filepath.Base(os.Getenv("SHELL")) + shell, err := detectShell() + if err != nil { + log.Fatal(err) + } + userShell = shell } + + t := template.New("envConfig") + + usageHint := generateUsageHint(c.Args().First(), userShell) + + shellCfg := ShellConfig{ + DockerCertPath: "", + DockerHost: "", + DockerTLSVerify: "", + } + + // unset vars if c.Bool("unset") { switch userShell { case "fish": - fmt.Printf("set -e DOCKER_TLS_VERIFY;\nset -e DOCKER_CERT_PATH;\nset -e DOCKER_HOST;\n") + shellCfg.Prefix = "set -e " + shellCfg.Delimiter = "" + shellCfg.Suffix = ";\n" case "powershell": - fmt.Printf("Remove-Item Env:\\DOCKER_TLS_VERIFY\nRemove-Item Env:\\DOCKER_CERT_PATH\nRemove-Item Env:\\DOCKER_HOST\n") + shellCfg.Prefix = "Remove-Item Env:\\\\" + shellCfg.Delimiter = "" + shellCfg.Suffix = "\n" + case "cmd": + // since there is no way to unset vars in cmd just reset to empty + shellCfg.DockerCertPath = "" + shellCfg.DockerHost = "" + shellCfg.DockerTLSVerify = "" + shellCfg.Prefix = "set " + shellCfg.Delimiter = "=" + shellCfg.Suffix = "\n" default: - fmt.Println("unset DOCKER_TLS_VERIFY DOCKER_CERT_PATH DOCKER_HOST") + shellCfg.Prefix = "unset " + shellCfg.Delimiter = " " + shellCfg.Suffix = "\n" + } + + tmpl, err := t.Parse(envTmpl) + if err != nil { + log.Fatal(err) + } + + if err := tmpl.Execute(os.Stdout, shellCfg); err != nil { + log.Fatal(err) } return } @@ -88,36 +141,59 @@ func cmdEnv(c *cli.Context) { } } - usageHint := generateUsageHint(c.Args().First(), userShell) + shellCfg = ShellConfig{ + DockerCertPath: cfg.machineDir, + DockerHost: dockerHost, + DockerTLSVerify: "1", + UsageHint: usageHint, + } switch userShell { case "fish": - fmt.Printf("set -x DOCKER_TLS_VERIFY 1;\nset -x DOCKER_CERT_PATH %q;\nset -x DOCKER_HOST %s;\n\n%s\n", - cfg.machineDir, dockerHost, usageHint) + shellCfg.Prefix = "set -x " + shellCfg.Suffix = ";\n" + shellCfg.Delimiter = " " case "powershell": - fmt.Printf("$Env:DOCKER_TLS_VERIFY = 1\n$Env:DOCKER_CERT_PATH = \"%s\"\n$Env:DOCKER_HOST = \"%s\"\n", - cfg.machineDir, dockerHost) + shellCfg.Prefix = "$Env:" + shellCfg.Suffix = "\"\n" + shellCfg.Delimiter = " = \"" + case "cmd": + shellCfg.Prefix = "set " + shellCfg.Suffix = "\n" + shellCfg.Delimiter = "=" default: - fmt.Printf("export DOCKER_TLS_VERIFY=1\nexport DOCKER_CERT_PATH=%q\nexport DOCKER_HOST=%s\n\n%s\n", - cfg.machineDir, dockerHost, usageHint) + shellCfg.Prefix = "export " + shellCfg.Suffix = "\n" + shellCfg.Delimiter = "=" + } + + tmpl, err := t.Parse(envTmpl) + if err != nil { + log.Fatal(err) + } + + if err := tmpl.Execute(os.Stdout, shellCfg); err != nil { + log.Fatal(err) } } func generateUsageHint(machineName string, userShell string) string { cmd := "" switch userShell { - case "powershell": - if machineName != "" { - cmd = fmt.Sprintf("Param(docker-machine env %s)", machineName) - } else { - cmd = "Param(docker-machine env)" - } case "fish": if machineName != "" { cmd = fmt.Sprintf("eval (docker-machine env %s)", machineName) } else { cmd = "eval (docker-machine env)" } + case "powershell": + if machineName != "" { + cmd = fmt.Sprintf("docker-machine env %s | Invoke-Expression", machineName) + } else { + cmd = "Param(docker-machine env)" + } + case "cmd": + cmd = "copy and paste the above values into your command prompt" default: if machineName != "" { cmd = fmt.Sprintf("eval \"$(docker-machine env %s)\"", machineName) diff --git a/ssh/keys.go b/ssh/keys.go index ce815fcbce..636a684b4b 100644 --- a/ssh/keys.go +++ b/ssh/keys.go @@ -12,7 +12,6 @@ import ( "io" "os" "runtime" - "syscall" gossh "golang.org/x/crypto/ssh" ) @@ -83,9 +82,7 @@ func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) erro // windows does not support chmod switch runtime.GOOS { - case "windows": - syscall.Chmod(f.Name(), 0600) - default: + case "darwin", "linux": if err := f.Chmod(0600); err != nil { return err } From 33d8058d38866c8f0f87a38eccd8927d0e2a2e48 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Tue, 21 Apr 2015 10:07:42 -0400 Subject: [PATCH 4/9] shell selection: fix tests and add powershell test Signed-off-by: Evan Hazlett --- commands/env.go | 8 ++-- commands/env_test.go | 107 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 107 insertions(+), 8 deletions(-) diff --git a/commands/env.go b/commands/env.go index 3e5e8b4df6..7449ff25eb 100644 --- a/commands/env.go +++ b/commands/env.go @@ -151,8 +151,8 @@ func cmdEnv(c *cli.Context) { switch userShell { case "fish": shellCfg.Prefix = "set -x " - shellCfg.Suffix = ";\n" - shellCfg.Delimiter = " " + shellCfg.Suffix = "\";\n" + shellCfg.Delimiter = " \"" case "powershell": shellCfg.Prefix = "$Env:" shellCfg.Suffix = "\"\n" @@ -163,8 +163,8 @@ func cmdEnv(c *cli.Context) { shellCfg.Delimiter = "=" default: shellCfg.Prefix = "export " - shellCfg.Suffix = "\n" - shellCfg.Delimiter = "=" + shellCfg.Suffix = "\"\n" + shellCfg.Delimiter = "=\"" } tmpl, err := t.Parse(envTmpl) diff --git a/commands/env_test.go b/commands/env_test.go index e65bd80d0d..0dc8192b23 100644 --- a/commands/env_test.go +++ b/commands/env_test.go @@ -103,9 +103,9 @@ func TestCmdEnvBash(t *testing.T) { testMachineDir := filepath.Join(store.GetPath(), "machines", host.Name) expected := map[string]string{ - "DOCKER_TLS_VERIFY": "1", + "DOCKER_TLS_VERIFY": "\"1\"", "DOCKER_CERT_PATH": fmt.Sprintf("\"%s\"", testMachineDir), - "DOCKER_HOST": "unix:///var/run/docker.sock", + "DOCKER_HOST": "\"unix:///var/run/docker.sock\"", } for k, v := range envvars { @@ -201,9 +201,108 @@ func TestCmdEnvFish(t *testing.T) { testMachineDir := filepath.Join(store.GetPath(), "machines", host.Name) expected := map[string]string{ - "DOCKER_TLS_VERIFY": "1", + "DOCKER_TLS_VERIFY": "\"1\"", "DOCKER_CERT_PATH": fmt.Sprintf("\"%s\"", testMachineDir), - "DOCKER_HOST": "unix:///var/run/docker.sock", + "DOCKER_HOST": "\"unix:///var/run/docker.sock\"", + } + + for k, v := range envvars { + if v != expected[k] { + t.Fatalf("Expected %s == <%s>, but was <%s>", k, expected[k], v) + } + } +} + +func TestCmdEnvPowerShell(t *testing.T) { + stdout := os.Stdout + shell := os.Getenv("SHELL") + r, w, _ := os.Pipe() + + os.Stdout = w + os.Setenv("MACHINE_STORAGE_PATH", TestStoreDir) + os.Setenv("SHELL", "") + + defer func() { + os.Setenv("MACHINE_STORAGE_PATH", "") + os.Setenv("SHELL", shell) + os.Stdout = stdout + }() + + if err := clearHosts(); err != nil { + t.Fatal(err) + } + + flags := getTestDriverFlags() + + store, sErr := getTestStore() + if sErr != nil { + t.Fatal(sErr) + } + + mcn, err := libmachine.New(store) + if err != nil { + t.Fatal(err) + } + + hostOptions := &libmachine.HostOptions{ + EngineOptions: &engine.EngineOptions{}, + SwarmOptions: &swarm.SwarmOptions{ + Master: false, + Discovery: "", + Address: "", + Host: "", + }, + AuthOptions: &auth.AuthOptions{}, + } + + host, err := mcn.Create("test-a", "none", hostOptions, flags) + if err != nil { + t.Fatal(err) + } + + host, err = mcn.Get("test-a") + if err != nil { + t.Fatalf("error loading host: %v", err) + } + + if err := mcn.SetActive(host); err != nil { + t.Fatalf("error setting active host: %v", err) + } + + outStr := make(chan string) + + go func() { + var testOutput bytes.Buffer + io.Copy(&testOutput, r) + outStr <- testOutput.String() + }() + + set := flag.NewFlagSet("config", 0) + set.String("shell", "powershell", "") + c := cli.NewContext(nil, set, set) + cmdEnv(c) + + w.Close() + + out := <-outStr + + // parse the output into a map of envvar:value for easier testing below + envvars := make(map[string]string) + for _, e := range strings.Split(strings.TrimSpace(out), "\n") { + if !strings.HasPrefix(e, "$Env") { + continue + } + kv := strings.SplitN(e, " = ", 2) + key, value := kv[0], kv[1] + envvars[strings.Replace(key, "$Env:", "", 1)] = value + } + + testMachineDir := filepath.Join(store.GetPath(), "machines", host.Name) + + expected := map[string]string{ + "DOCKER_TLS_VERIFY": "\"1\"", + "DOCKER_CERT_PATH": fmt.Sprintf("\"%s\"", testMachineDir), + "DOCKER_HOST": "\"unix:///var/run/docker.sock\"", } for k, v := range envvars { From 6b735677a035cbb3f2cb8613874efeec111c1a2f Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Wed, 22 Apr 2015 14:08:26 -0400 Subject: [PATCH 5/9] do not hard code machine binary name in env command Signed-off-by: Evan Hazlett --- commands/env.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/commands/env.go b/commands/env.go index 7449ff25eb..9545d19d22 100644 --- a/commands/env.go +++ b/commands/env.go @@ -39,7 +39,7 @@ func cmdEnv(c *cli.Context) { t := template.New("envConfig") - usageHint := generateUsageHint(c.Args().First(), userShell) + usageHint := generateUsageHint(c.App.Name, c.Args().First(), userShell) shellCfg := ShellConfig{ DockerCertPath: "", @@ -89,7 +89,7 @@ func cmdEnv(c *cli.Context) { } if cfg.machineUrl == "" { - log.Fatalf("%s is not running. Please start this with docker-machine start %s", cfg.machineName, cfg.machineName) + log.Fatalf("%s is not running. Please start this with %s start %s", cfg.machineName, c.App.Name, cfg.machineName) } dockerHost := cfg.machineUrl @@ -177,28 +177,28 @@ func cmdEnv(c *cli.Context) { } } -func generateUsageHint(machineName string, userShell string) string { +func generateUsageHint(appName, machineName, userShell string) string { cmd := "" switch userShell { case "fish": if machineName != "" { - cmd = fmt.Sprintf("eval (docker-machine env %s)", machineName) + cmd = fmt.Sprintf("eval (%s env %s)", appName, machineName) } else { - cmd = "eval (docker-machine env)" + cmd = fmt.Sprintf("eval (%s env)", appName) } case "powershell": if machineName != "" { - cmd = fmt.Sprintf("docker-machine env %s | Invoke-Expression", machineName) + cmd = fmt.Sprintf("%s env %s | Invoke-Expression", appName, machineName) } else { - cmd = "Param(docker-machine env)" + cmd = fmt.Sprintf("Param(%s env)", appName) } case "cmd": cmd = "copy and paste the above values into your command prompt" default: if machineName != "" { - cmd = fmt.Sprintf("eval \"$(docker-machine env %s)\"", machineName) + cmd = fmt.Sprintf("eval \"$(%s env %s)\"", appName, machineName) } else { - cmd = "eval \"$(docker-machine env)\"" + cmd = fmt.Sprintf("eval \"$(%s env)\"", appName) } } From 92f6b45de28c1cf8186accb4a66089d2d4c56401 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Thu, 23 Apr 2015 15:04:16 -0400 Subject: [PATCH 6/9] env-shell: fixed tests Signed-off-by: Evan Hazlett --- commands/env_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/commands/env_test.go b/commands/env_test.go index 0dc8192b23..a90aa63b23 100644 --- a/commands/env_test.go +++ b/commands/env_test.go @@ -83,6 +83,9 @@ func TestCmdEnvBash(t *testing.T) { set := flag.NewFlagSet("config", 0) c := cli.NewContext(nil, set, set) + c.App = &cli.App{ + Name: "docker-machine-test", + } cmdEnv(c) w.Close() @@ -181,6 +184,9 @@ func TestCmdEnvFish(t *testing.T) { set := flag.NewFlagSet("config", 0) c := cli.NewContext(nil, set, set) + c.App = &cli.App{ + Name: "docker-machine-test", + } cmdEnv(c) w.Close() @@ -280,6 +286,9 @@ func TestCmdEnvPowerShell(t *testing.T) { set := flag.NewFlagSet("config", 0) set.String("shell", "powershell", "") c := cli.NewContext(nil, set, set) + c.App = &cli.App{ + Name: "docker-machine-test", + } cmdEnv(c) w.Close() From 9aa861ea55f35a7f344b3ad4e65685f70c6aec05 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Thu, 23 Apr 2015 15:06:50 -0400 Subject: [PATCH 7/9] update usage hint for powershell Signed-off-by: Evan Hazlett --- commands/env.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/env.go b/commands/env.go index 9545d19d22..79059c7c12 100644 --- a/commands/env.go +++ b/commands/env.go @@ -188,9 +188,9 @@ func generateUsageHint(appName, machineName, userShell string) string { } case "powershell": if machineName != "" { - cmd = fmt.Sprintf("%s env %s | Invoke-Expression", appName, machineName) + cmd = fmt.Sprintf("%s env --shell=powershell %s | Invoke-Expression", appName, machineName) } else { - cmd = fmt.Sprintf("Param(%s env)", appName) + cmd = fmt.Sprintf("%s env --shell=powershell | Invoke-Expression", appName) } case "cmd": cmd = "copy and paste the above values into your command prompt" From 49686b9a91dba23b9715ae2db6d189e3721e96c0 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Thu, 30 Apr 2015 10:36:38 -0400 Subject: [PATCH 8/9] better hint for windows shells Signed-off-by: Evan Hazlett --- commands/commands.go | 5 +++-- commands/create.go | 18 ++---------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/commands/commands.go b/commands/commands.go index 20536caa65..8aae28cfb1 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "sort" "strings" @@ -658,8 +659,8 @@ func detectShell() (string, error) { // attempt to get the SHELL env var shell := filepath.Base(os.Getenv("SHELL")) // none detected; check for windows env - if shell == "." && os.Getenv("windir") != "" { - log.Printf("On Windows, please specify either cmd or powershell with the --shell flag.\n\n") + if runtime.GOOS == "windows" { + log.Printf("On Windows, please specify either 'cmd' or 'powershell' with the --shell flag.\n\n") return "", ErrUnknownShell } diff --git a/commands/create.go b/commands/create.go index 5d00d8e705..db36895762 100644 --- a/commands/create.go +++ b/commands/create.go @@ -2,7 +2,6 @@ package commands import ( "fmt" - "os" "path/filepath" log "github.com/Sirupsen/logrus" @@ -89,21 +88,8 @@ func cmdCreate(c *cli.Context) { log.Fatalf("error setting active host: %v", err) } - info := "" - userShell := filepath.Base(os.Getenv("SHELL")) - - switch userShell { - case "fish": - info = fmt.Sprintf("%s env %s | source", c.App.Name, name) - default: - info = fmt.Sprintf(`eval "$(%s env %s)"`, c.App.Name, name) - } - - log.Infof("%q has been created and is now the active machine.", name) - - if info != "" { - log.Infof("To point your Docker client at it, run this in your shell: %s", info) - } + info := fmt.Sprintf("%s env %s", c.App.Name, name) + log.Infof("To point your Docker client at it, run this in your shell: %s", info) } // If the user has specified a driver, they should not see the flags for all From 6fe4331fddde2e9ff6e878854260d30a50ba9287 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Thu, 30 Apr 2015 10:36:59 -0400 Subject: [PATCH 9/9] vbox: stop before rm for stability Signed-off-by: Evan Hazlett --- drivers/virtualbox/virtualbox.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtualbox/virtualbox.go b/drivers/virtualbox/virtualbox.go index 30eb546ce1..8de7d9f275 100644 --- a/drivers/virtualbox/virtualbox.go +++ b/drivers/virtualbox/virtualbox.go @@ -424,7 +424,7 @@ func (d *Driver) Remove() error { return err } if s == state.Running { - if err := d.Kill(); err != nil { + if err := d.Stop(); err != nil { return err } }