Browse code

Make .dockercfg with json.MarshallIndent

Fixes #10129
Makes the .dockercfg more human parsable.

Also cleaned up the (technically) racey login test.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Brian Goff authored on 2015/01/16 23:47:32
Showing 2 changed files
... ...
@@ -2,7 +2,6 @@ package main
2 2
 
3 3
 import (
4 4
 	"bytes"
5
-	"io"
6 5
 	"os/exec"
7 6
 	"testing"
8 7
 )
... ...
@@ -10,17 +9,8 @@ import (
10 10
 func TestLoginWithoutTTY(t *testing.T) {
11 11
 	cmd := exec.Command(dockerBinary, "login")
12 12
 
13
-	// create a buffer with text then a new line as a return
14
-	buf := bytes.NewBuffer([]byte("buffer test string \n"))
15
-
16
-	// use a pipe for stdin and manually copy the data so that
17
-	// the process does not get the TTY
18
-	in, err := cmd.StdinPipe()
19
-	if err != nil {
20
-		t.Fatal(err)
21
-	}
22
-	// copy the bytes into the commands stdin along with a new line
23
-	go io.Copy(in, buf)
13
+	// Send to stdin so the process does not get the TTY
14
+	cmd.Stdin = bytes.NewBufferString("buffer test string \n")
24 15
 
25 16
 	// run the command and block until it's done
26 17
 	if err := cmd.Run(); err == nil {
... ...
@@ -133,7 +133,7 @@ func SaveConfig(configFile *ConfigFile) error {
133 133
 		configs[k] = authCopy
134 134
 	}
135 135
 
136
-	b, err := json.Marshal(configs)
136
+	b, err := json.MarshalIndent(configs, "", "\t")
137 137
 	if err != nil {
138 138
 		return err
139 139
 	}