зеркало из https://github.com/microsoft/docker.git
fix docker build and docker events output
This commit is contained in:
Родитель
c3027fa9ac
Коммит
213365c2d2
|
@ -422,7 +422,7 @@ func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgID, endpoin
|
|||
// FIXME: Launch the getRemoteImage() in goroutines
|
||||
for _, id := range history {
|
||||
if !srv.runtime.graph.Exists(id) {
|
||||
out.Write(sf.FormatStatus(utils.TruncateID(id), "Pulling metadata"))
|
||||
out.Write(sf.FormatProgress(utils.TruncateID(id), "Pulling", "metadata"))
|
||||
imgJSON, imgSize, err := r.GetRemoteImageJSON(id, endpoint, token)
|
||||
if err != nil {
|
||||
// FIXME: Keep goging in case of error?
|
||||
|
@ -434,7 +434,7 @@ func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgID, endpoin
|
|||
}
|
||||
|
||||
// Get the layer
|
||||
out.Write(sf.FormatStatus(utils.TruncateID(id), "Pulling fs layer"))
|
||||
out.Write(sf.FormatProgress(utils.TruncateID(id), "Pulling", "fs layer"))
|
||||
layer, err := r.GetRemoteImageLayer(img.ID, endpoint, token)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -500,7 +500,7 @@ func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, localName
|
|||
errors <- nil
|
||||
return
|
||||
}
|
||||
out.Write(sf.FormatStatus(utils.TruncateID(img.ID), "Pulling image (%s) from %s", img.Tag, localName))
|
||||
out.Write(sf.FormatProgress(utils.TruncateID(img.ID), "Pulling", fmt.Sprintf("image (%s) from %s", img.Tag, localName)))
|
||||
success := false
|
||||
for _, ep := range repoData.Endpoints {
|
||||
if err := srv.pullImage(r, out, img.ID, ep, repoData.Tokens, sf); err != nil {
|
||||
|
@ -716,11 +716,12 @@ func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgID,
|
|||
}
|
||||
|
||||
// Send the layer
|
||||
if checksum, err := r.PushImageLayerRegistry(imgData.ID, utils.ProgressReader(layerData, int(layerData.Size), out, sf.FormatProgress("", "Pushing", "%8v/%v (%v)"), sf, true), ep, token, jsonRaw); err != nil {
|
||||
if checksum, err := r.PushImageLayerRegistry(imgData.ID, utils.ProgressReader(layerData, int(layerData.Size), out, sf.FormatProgress("", "Pushing", "%8v/%v (%v)"), sf, false), ep, token, jsonRaw); err != nil {
|
||||
return "", err
|
||||
} else {
|
||||
imgData.Checksum = checksum
|
||||
}
|
||||
out.Write(sf.FormatStatus("", ""))
|
||||
|
||||
// Send the checksum
|
||||
if err := r.PushImageChecksumRegistry(imgData, ep, token); err != nil {
|
||||
|
|
|
@ -79,7 +79,6 @@ type progressReader struct {
|
|||
func (r *progressReader) Read(p []byte) (n int, err error) {
|
||||
read, err := io.ReadCloser(r.reader).Read(p)
|
||||
r.readProgress += read
|
||||
|
||||
updateEvery := 1024 * 512 //512kB
|
||||
if r.readTotal > 0 {
|
||||
// Update progress for every 1% read if 1% < 512kB
|
||||
|
@ -645,7 +644,6 @@ func (jm *JSONMessage) Display(out io.Writer) error {
|
|||
}
|
||||
return jm.Error
|
||||
}
|
||||
fmt.Fprintf(out, "%c[2K", 27)
|
||||
if jm.Time != 0 {
|
||||
fmt.Fprintf(out, "[%s] ", time.Unix(jm.Time, 0))
|
||||
}
|
||||
|
@ -653,28 +651,26 @@ func (jm *JSONMessage) Display(out io.Writer) error {
|
|||
fmt.Fprintf(out, "%s: ", jm.ID)
|
||||
}
|
||||
if jm.Progress != "" {
|
||||
fmt.Fprintf(out, "%c[2K", 27)
|
||||
fmt.Fprintf(out, "%s %s\r", jm.Status, jm.Progress)
|
||||
} else {
|
||||
fmt.Fprintf(out, "%s\r", jm.Status)
|
||||
}
|
||||
if jm.ID == "" {
|
||||
fmt.Fprintf(out, "\n")
|
||||
fmt.Fprintf(out, "%s\r\n", jm.Status)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DisplayJSONMessagesStream(in io.Reader, out io.Writer) error {
|
||||
dec := json.NewDecoder(in)
|
||||
jm := JSONMessage{}
|
||||
ids := make(map[string]int)
|
||||
diff := 0
|
||||
for {
|
||||
jm := JSONMessage{}
|
||||
if err := dec.Decode(&jm); err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
if jm.ID != "" {
|
||||
if jm.Progress != "" && jm.ID != "" {
|
||||
line, ok := ids[jm.ID]
|
||||
if !ok {
|
||||
line = len(ids)
|
||||
|
|
Загрузка…
Ссылка в новой задаче