Browse code

Return AuthResponse from postAuth api endpoint, Fixes #11607

Signed-off-by: Antonio Murdaca <me@runcom.ninja>

Antonio Murdaca authored on 2015/03/24 07:32:50
Showing 3 changed files
... ...
@@ -450,17 +450,18 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
450 450
 	if err != nil {
451 451
 		return err
452 452
 	}
453
-	var out2 engine.Env
454
-	err = out2.Decode(stream)
455
-	if err != nil {
453
+
454
+	var response types.AuthResponse
455
+	if err := json.NewDecoder(stream).Decode(response); err != nil {
456 456
 		cli.configFile, _ = registry.LoadConfig(homedir.Get())
457 457
 		return err
458 458
 	}
459
+
459 460
 	registry.SaveConfig(cli.configFile)
460 461
 	fmt.Fprintf(cli.out, "WARNING: login credentials saved in %s.\n", path.Join(homedir.Get(), registry.CONFIGFILE))
461 462
 
462
-	if out2.Get("Status") != "" {
463
-		fmt.Fprintf(cli.out, "%s\n", out2.Get("Status"))
463
+	if response.Status != "" {
464
+		fmt.Fprintf(cli.out, "%s\n", response.Status)
464 465
 	}
465 466
 	return nil
466 467
 }
... ...
@@ -192,7 +192,9 @@ func postAuth(eng *engine.Engine, version version.Version, w http.ResponseWriter
192 192
 	if status := engine.Tail(stdoutBuffer, 1); status != "" {
193 193
 		var env engine.Env
194 194
 		env.Set("Status", status)
195
-		return writeJSONEnv(w, http.StatusOK, env)
195
+		return writeJSON(w, http.StatusOK, &types.AuthResponse{
196
+			Status: status,
197
+		})
196 198
 	}
197 199
 	w.WriteHeader(http.StatusNoContent)
198 200
 	return nil
... ...
@@ -18,3 +18,9 @@ type ContainerExecCreateResponse struct {
18 18
 	// Warnings are any warnings encountered during the execution of the command.
19 19
 	Warnings []string `json:"Warnings"`
20 20
 }
21
+
22
+// POST /auth
23
+type AuthResponse struct {
24
+	// Status is the authentication status
25
+	Status string `json:"Status"`
26
+}