X Tutup
Skip to content

Commit f155bc9

Browse files
committed
Merge pull request docker-archive-public#2073 from nathanleclaire/fix_cert_env
Fix cert env
2 parents e421a07 + b038ff4 commit f155bc9

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

commands/env.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import (
44
"errors"
55
"fmt"
66
"os"
7+
"path/filepath"
78
"strings"
89
"text/template"
910

1011
"github.com/docker/machine/cli"
12+
"github.com/docker/machine/commands/mcndirs"
1113
"github.com/docker/machine/libmachine/log"
1214
)
1315

@@ -47,7 +49,7 @@ func cmdEnv(c *cli.Context) {
4749

4850
h := getFirstArgHost(c)
4951

50-
dockerHost, authOptions, err := runConnectionBoilerplate(h, c)
52+
dockerHost, _, err := runConnectionBoilerplate(h, c)
5153
if err != nil {
5254
fatalf("Error running connection boilerplate: %s", err)
5355
}
@@ -66,7 +68,7 @@ func cmdEnv(c *cli.Context) {
6668
usageHint := generateUsageHint(c.App.Name, c.Args().First(), userShell, c)
6769

6870
shellCfg := &ShellConfig{
69-
DockerCertPath: authOptions.CertDir,
71+
DockerCertPath: filepath.Join(mcndirs.GetMachineDir(), h.Name),
7072
DockerHost: dockerHost,
7173
DockerTLSVerify: "1",
7274
UsageHint: usageHint,

test/integration/core/env_shell.bats

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ load ${BASE_TEST_DIR}/helpers.bash
1111
run machine env --shell powershell --no-proxy $NAME
1212
[[ ${lines[0]} == "\$Env:DOCKER_TLS_VERIFY = \"1\"" ]]
1313
[[ ${lines[1]} == "\$Env:DOCKER_HOST = \"$(machine url $NAME)\"" ]]
14-
[[ ${lines[2]} == "\$Env:DOCKER_CERT_PATH = \"$MACHINE_STORAGE_PATH/certs\"" ]]
14+
[[ ${lines[2]} == "\$Env:DOCKER_CERT_PATH = \"$MACHINE_STORAGE_PATH/machines/$NAME\"" ]]
1515
[[ ${lines[3]} == "\$Env:DOCKER_MACHINE_NAME = \"$NAME\"" ]]
1616
[[ ${lines[4]} == "\$Env:NO_PROXY = \"$(machine ip $NAME)\"" ]]
1717
}
@@ -20,25 +20,25 @@ load ${BASE_TEST_DIR}/helpers.bash
2020
run machine env --no-proxy $NAME
2121
[[ ${lines[0]} == "export DOCKER_TLS_VERIFY=\"1\"" ]]
2222
[[ ${lines[1]} == "export DOCKER_HOST=\"$(machine url $NAME)\"" ]]
23-
[[ ${lines[2]} == "export DOCKER_CERT_PATH=\"$MACHINE_STORAGE_PATH/certs\"" ]]
23+
[[ ${lines[2]} == "export DOCKER_CERT_PATH=\"$MACHINE_STORAGE_PATH/machines/$NAME\"" ]]
2424
[[ ${lines[3]} == "export DOCKER_MACHINE_NAME=\"$NAME\"" ]]
2525
[[ ${lines[4]} == "export NO_PROXY=\"$(machine ip $NAME)\"" ]]
2626
}
2727

2828
@test "$DRIVER: test cmd.exe notation" {
2929
run machine env --shell cmd --no-proxy $NAME
30-
[[ ${lines[0]} == "set DOCKER_TLS_VERIFY=1" ]]
31-
[[ ${lines[1]} == "set DOCKER_HOST=$(machine url $NAME)" ]]
32-
[[ ${lines[2]} == "set DOCKER_CERT_PATH=$MACHINE_STORAGE_PATH/certs" ]]
33-
[[ ${lines[3]} == "set DOCKER_MACHINE_NAME=$NAME" ]]
34-
[[ ${lines[4]} == "set NO_PROXY=$(machine ip $NAME)" ]]
30+
[[ ${lines[0]} == "SET DOCKER_TLS_VERIFY=1" ]]
31+
[[ ${lines[1]} == "SET DOCKER_HOST=$(machine url $NAME)" ]]
32+
[[ ${lines[2]} == "SET DOCKER_CERT_PATH=$MACHINE_STORAGE_PATH/machines/$NAME" ]]
33+
[[ ${lines[3]} == "SET DOCKER_MACHINE_NAME=$NAME" ]]
34+
[[ ${lines[4]} == "SET NO_PROXY=$(machine ip $NAME)" ]]
3535
}
3636

3737
@test "$DRIVER: test fish notation" {
3838
run machine env --shell fish --no-proxy $NAME
3939
[[ ${lines[0]} == "set -x DOCKER_TLS_VERIFY \"1\";" ]]
4040
[[ ${lines[1]} == "set -x DOCKER_HOST \"$(machine url $NAME)\";" ]]
41-
[[ ${lines[2]} == "set -x DOCKER_CERT_PATH \"$MACHINE_STORAGE_PATH/certs\";" ]]
41+
[[ ${lines[2]} == "set -x DOCKER_CERT_PATH \"$MACHINE_STORAGE_PATH/machines/$NAME\";" ]]
4242
[[ ${lines[3]} == "set -x DOCKER_MACHINE_NAME \"$NAME\";" ]]
4343
[[ ${lines[4]} == "set -x NO_PROXY \"$(machine ip $NAME)\";" ]]
4444
}

0 commit comments

Comments
 (0)
X Tutup