Defer creation of trust key file until needed

Fixes #10442

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan
2015-01-29 13:46:12 -08:00
parent b505db5e3c
commit 0eed1f4d8d
6 changed files with 24 additions and 60 deletions
+3 -4
View File
@@ -17,7 +17,6 @@ import (
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/term"
"github.com/docker/docker/registry"
"github.com/docker/libtrust"
)
type DockerCli struct {
@@ -27,7 +26,7 @@ type DockerCli struct {
in io.ReadCloser
out io.Writer
err io.Writer
key libtrust.PrivateKey
keyFile string
tlsConfig *tls.Config
scheme string
// inFd holds file descriptor of the client's STDIN, if it's a valid file
@@ -122,7 +121,7 @@ func (cli *DockerCli) CheckTtyInput(attachStdin, ttyMode bool) error {
return nil
}
func NewDockerCli(in io.ReadCloser, out, err io.Writer, key libtrust.PrivateKey, proto, addr string, tlsConfig *tls.Config) *DockerCli {
func NewDockerCli(in io.ReadCloser, out, err io.Writer, keyFile string, proto, addr string, tlsConfig *tls.Config) *DockerCli {
var (
inFd uintptr
outFd uintptr
@@ -177,7 +176,7 @@ func NewDockerCli(in io.ReadCloser, out, err io.Writer, key libtrust.PrivateKey,
in: in,
out: out,
err: err,
key: key,
keyFile: keyFile,
inFd: inFd,
outFd: outFd,
isTerminalIn: isTerminalIn,
+5 -1
View File
@@ -1191,6 +1191,10 @@ func (cli *DockerCli) CmdPush(args ...string) error {
name := cmd.Arg(0)
cli.LoadConfigFile()
trustKey, err := api.LoadOrCreateTrustKey(cli.keyFile)
if err != nil {
log.Fatal(err)
}
remote, tag := parsers.ParseRepositoryTag(name)
@@ -1225,7 +1229,7 @@ func (cli *DockerCli) CmdPush(args ...string) error {
if err != nil {
return err
}
err = js.Sign(cli.key)
err = js.Sign(trustKey)
if err != nil {
return err
}