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>
This commit is contained in:
parent
4245952f79
commit
b8f7526fc6
2 changed files with 3 additions and 13 deletions
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
@ -10,17 +9,8 @@ import (
|
||||||
func TestLoginWithoutTTY(t *testing.T) {
|
func TestLoginWithoutTTY(t *testing.T) {
|
||||||
cmd := exec.Command(dockerBinary, "login")
|
cmd := exec.Command(dockerBinary, "login")
|
||||||
|
|
||||||
// create a buffer with text then a new line as a return
|
// Send to stdin so the process does not get the TTY
|
||||||
buf := bytes.NewBuffer([]byte("buffer test string \n"))
|
cmd.Stdin = bytes.NewBufferString("buffer test string \n")
|
||||||
|
|
||||||
// use a pipe for stdin and manually copy the data so that
|
|
||||||
// the process does not get the TTY
|
|
||||||
in, err := cmd.StdinPipe()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
// copy the bytes into the commands stdin along with a new line
|
|
||||||
go io.Copy(in, buf)
|
|
||||||
|
|
||||||
// run the command and block until it's done
|
// run the command and block until it's done
|
||||||
if err := cmd.Run(); err == nil {
|
if err := cmd.Run(); err == nil {
|
||||||
|
|
|
@ -133,7 +133,7 @@ func SaveConfig(configFile *ConfigFile) error {
|
||||||
configs[k] = authCopy
|
configs[k] = authCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := json.Marshal(configs)
|
b, err := json.MarshalIndent(configs, "", "\t")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue