mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #4930 from vieux/fix_regression_import
Fix regression import
This commit is contained in:
commit
cd0a907325
2 changed files with 25 additions and 7 deletions
20
integration-cli/docker_cli_import_test.go
Normal file
20
integration-cli/docker_cli_import_test.go
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestImportDisplay(t *testing.T) {
|
||||||
|
importCmd := exec.Command(dockerBinary, "import", "https://github.com/ewindisch/docker-cirros/raw/master/cirros-0.3.0-x86_64-lxc.tar.gz")
|
||||||
|
out, _, err := runCommandWithOutput(importCmd)
|
||||||
|
errorOut(err, t, fmt.Sprintf("import failed with errors: %v", err))
|
||||||
|
|
||||||
|
if n := len(strings.Split(out, "\n")); n != 3 {
|
||||||
|
t.Fatalf("display is messed up: %d '\\n' instead of 3", n)
|
||||||
|
}
|
||||||
|
|
||||||
|
logDone("import - cirros was imported and display is fine")
|
||||||
|
}
|
|
@ -131,7 +131,7 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr,
|
||||||
if jm.Progress != nil {
|
if jm.Progress != nil {
|
||||||
jm.Progress.terminalFd = terminalFd
|
jm.Progress.terminalFd = terminalFd
|
||||||
}
|
}
|
||||||
if jm.Progress != nil || jm.ProgressMessage != "" {
|
if jm.ID != "" && (jm.Progress != nil || jm.ProgressMessage != "") {
|
||||||
line, ok := ids[jm.ID]
|
line, ok := ids[jm.ID]
|
||||||
if !ok {
|
if !ok {
|
||||||
line = len(ids)
|
line = len(ids)
|
||||||
|
@ -141,17 +141,15 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr,
|
||||||
} else {
|
} else {
|
||||||
diff = len(ids) - line
|
diff = len(ids) - line
|
||||||
}
|
}
|
||||||
if isTerminal {
|
if jm.ID != "" && isTerminal {
|
||||||
// <ESC>[{diff}A = move cursor up diff rows
|
// <ESC>[{diff}A = move cursor up diff rows
|
||||||
fmt.Fprintf(out, "%c[%dA", 27, diff)
|
fmt.Fprintf(out, "%c[%dA", 27, diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err := jm.Display(out, isTerminal)
|
err := jm.Display(out, isTerminal)
|
||||||
if jm.ID != "" {
|
if jm.ID != "" && isTerminal {
|
||||||
if isTerminal {
|
// <ESC>[{diff}B = move cursor down diff rows
|
||||||
// <ESC>[{diff}B = move cursor down diff rows
|
fmt.Fprintf(out, "%c[%dB", 27, diff)
|
||||||
fmt.Fprintf(out, "%c[%dB", 27, diff)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue