Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Arnaud Porterie authored on 2016/02/04 03:30:17... | ... |
@@ -11,7 +11,6 @@ import ( |
11 | 11 |
Cli "github.com/docker/docker/cli" |
12 | 12 |
flag "github.com/docker/docker/pkg/mflag" |
13 | 13 |
"github.com/docker/docker/pkg/term" |
14 |
- "github.com/docker/docker/registry" |
|
15 | 14 |
"github.com/docker/engine-api/client" |
16 | 15 |
"github.com/docker/engine-api/types" |
17 | 16 |
) |
... | ... |
@@ -36,16 +35,7 @@ func (cli *DockerCli) CmdLogin(args ...string) error { |
36 | 36 |
cli.in = os.Stdin |
37 | 37 |
} |
38 | 38 |
|
39 |
- // The daemon `/info` endpoint informs us of the default registry being |
|
40 |
- // used. This is essential in cross-platforms environment, where for |
|
41 |
- // example a Linux client might be interacting with a Windows daemon, hence |
|
42 |
- // the default registry URL might be Windows specific. |
|
43 |
- serverAddress := registry.IndexServer |
|
44 |
- if info, err := cli.client.Info(); err != nil { |
|
45 |
- fmt.Fprintf(cli.out, "Warning: failed to get default registry endpoint from daemon (%v). Using system default: %s\n", err, serverAddress) |
|
46 |
- } else { |
|
47 |
- serverAddress = info.IndexServerAddress |
|
48 |
- } |
|
39 |
+ serverAddress := cli.electAuthServer() |
|
49 | 40 |
if len(cmd.Args()) > 0 { |
50 | 41 |
serverAddress = cmd.Arg(0) |
51 | 42 |
} |
... | ... |
@@ -5,7 +5,6 @@ import ( |
5 | 5 |
|
6 | 6 |
Cli "github.com/docker/docker/cli" |
7 | 7 |
flag "github.com/docker/docker/pkg/mflag" |
8 |
- "github.com/docker/docker/registry" |
|
9 | 8 |
) |
10 | 9 |
|
11 | 10 |
// CmdLogout logs a user out from a Docker registry. |
... | ... |
@@ -14,12 +13,12 @@ import ( |
14 | 14 |
// |
15 | 15 |
// Usage: docker logout [SERVER] |
16 | 16 |
func (cli *DockerCli) CmdLogout(args ...string) error { |
17 |
- cmd := Cli.Subcmd("logout", []string{"[SERVER]"}, Cli.DockerCommands["logout"].Description+".\nIf no server is specified \""+registry.IndexServer+"\" is the default.", true) |
|
17 |
+ cmd := Cli.Subcmd("logout", []string{"[SERVER]"}, Cli.DockerCommands["logout"].Description+".\nIf no server is specified, the default is defined by the daemon.", true) |
|
18 | 18 |
cmd.Require(flag.Max, 1) |
19 | 19 |
|
20 | 20 |
cmd.ParseFlags(args, true) |
21 | 21 |
|
22 |
- serverAddress := registry.IndexServer |
|
22 |
+ serverAddress := cli.electAuthServer() |
|
23 | 23 |
if len(cmd.Args()) > 0 { |
24 | 24 |
serverAddress = cmd.Arg(0) |
25 | 25 |
} |
... | ... |
@@ -18,6 +18,20 @@ import ( |
18 | 18 |
registrytypes "github.com/docker/engine-api/types/registry" |
19 | 19 |
) |
20 | 20 |
|
21 |
+func (cli *DockerCli) electAuthServer() string { |
|
22 |
+ // The daemon `/info` endpoint informs us of the default registry being |
|
23 |
+ // used. This is essential in cross-platforms environment, where for |
|
24 |
+ // example a Linux client might be interacting with a Windows daemon, hence |
|
25 |
+ // the default registry URL might be Windows specific. |
|
26 |
+ serverAddress := registry.IndexServer |
|
27 |
+ if info, err := cli.client.Info(); err != nil { |
|
28 |
+ fmt.Fprintf(cli.out, "Warning: failed to get default registry endpoint from daemon (%v). Using system default: %s\n", err, serverAddress) |
|
29 |
+ } else { |
|
30 |
+ serverAddress = info.IndexServerAddress |
|
31 |
+ } |
|
32 |
+ return serverAddress |
|
33 |
+} |
|
34 |
+ |
|
21 | 35 |
// encodeAuthToBase64 serializes the auth configuration as JSON base64 payload |
22 | 36 |
func encodeAuthToBase64(authConfig types.AuthConfig) (string, error) { |
23 | 37 |
buf, err := json.Marshal(authConfig) |