From 3922691fb99a99cec0a5d239da522cc3d8778e6c Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 4 Jun 2013 16:09:08 +0000 Subject: [PATCH 1/2] fix progress message in client --- commands.go | 2 +- docs/sources/api/docker_remote_api.rst | 6 +++--- server.go | 2 +- utils/utils.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commands.go b/commands.go index c38c18a04c..93bae63a29 100644 --- a/commands.go +++ b/commands.go @@ -1379,7 +1379,7 @@ func (cli *DockerCli) stream(method, path string, in io.Reader, out io.Writer) e return err } if m.Progress != "" { - fmt.Fprintf(out, "Downloading %s\r", m.Progress) + fmt.Fprintf(out, "%s %s\r", m.Status, m.Progress) } else if m.Error != "" { return fmt.Errorf(m.Error) } else { diff --git a/docs/sources/api/docker_remote_api.rst b/docs/sources/api/docker_remote_api.rst index dca4599c55..1c46cf148a 100644 --- a/docs/sources/api/docker_remote_api.rst +++ b/docs/sources/api/docker_remote_api.rst @@ -564,7 +564,7 @@ Create an image Content-Type: application/json {"status":"Pulling..."} - {"progress":"1/? (n/a)"} + {"status":"Pulling", "progress":"1/? (n/a)"} {"error":"Invalid..."} ... @@ -607,7 +607,7 @@ Insert a file in a image Content-Type: application/json {"status":"Inserting..."} - {"progress":"1/? (n/a)"} + {"status":"Inserting", "progress":"1/? (n/a)"} {"error":"Invalid..."} ... @@ -734,7 +734,7 @@ Push an image on the registry Content-Type: application/json {"status":"Pushing..."} - {"progress":"1/? (n/a)"} + {"status":"Pushing", "progress":"1/? (n/a)"} {"error":"Invalid..."} ... diff --git a/server.go b/server.go index 08cb37a72e..ec2157d803 100644 --- a/server.go +++ b/server.go @@ -573,7 +573,7 @@ func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgId, } // Send the layer - if err := r.PushImageLayerRegistry(imgData.Id, utils.ProgressReader(layerData, int(layerData.Size), out, sf.FormatProgress("", "%v/%v (%v)"), sf), ep, token); err != nil { + if err := r.PushImageLayerRegistry(imgData.Id, utils.ProgressReader(layerData, int(layerData.Size), out, sf.FormatProgress("Pushing", "%v/%v (%v)"), sf), ep, token); err != nil { return err } return nil diff --git a/utils/utils.go b/utils/utils.go index 33aa2eba8c..2cd23ad6d2 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -608,7 +608,7 @@ func (sf *StreamFormatter) FormatError(err error) []byte { func (sf *StreamFormatter) FormatProgress(action, str string) []byte { sf.used = true if sf.json { - b, err := json.Marshal(&JsonMessage{Progress:str}) + b, err := json.Marshal(&JsonMessage{Status: action, Progress:str}) if err != nil { return nil } From 7e6ede63794b54bcc0d67d86ea60e76b701d286f Mon Sep 17 00:00:00 2001 From: Louis Opter Date: Tue, 4 Jun 2013 15:24:25 -0700 Subject: [PATCH 2/2] Print the container id before the hijack in `docker run` (see also #804) This is useful when you want to get the container id before you start to interact with stdin (which is what I'm doing in dotcloud/sandbox). --- commands.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commands.go b/commands.go index f12e9bcb11..71a6f87e04 100644 --- a/commands.go +++ b/commands.go @@ -1228,6 +1228,9 @@ func (cli *DockerCli) CmdRun(args ...string) error { return err } + if !config.AttachStdout && !config.AttachStderr { + fmt.Println(out.ID) + } if connections > 0 { chErrors := make(chan error, connections) cli.monitorTtySize(out.ID) @@ -1262,9 +1265,6 @@ func (cli *DockerCli) CmdRun(args ...string) error { connections -= 1 } } - if !config.AttachStdout && !config.AttachStderr { - fmt.Println(out.ID) - } return nil }