浏览代码

fix progress message in client

Victor Vieux 12 年之前
父节点
当前提交
3922691fb9
共有 4 个文件被更改,包括 6 次插入6 次删除
  1. 1 1
      commands.go
  2. 3 3
      docs/sources/api/docker_remote_api.rst
  3. 1 1
      server.go
  4. 1 1
      utils/utils.go

+ 1 - 1
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 {

+ 3 - 3
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..."}
 	   ...
 

+ 1 - 1
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

+ 1 - 1
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
                 }