Sfoglia il codice sorgente

Merge pull request #1516 from docker/version_json

don't include stderr in moby exec output
Nicolas De loof 4 anni fa
parent
commit
0b968395dd
2 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  1. 2 1
      cli/mobycli/exec.go
  2. 2 3
      local/e2e/cli-only/e2e_test.go

+ 2 - 1
cli/mobycli/exec.go

@@ -136,5 +136,6 @@ func ExecSilent(ctx context.Context, args ...string) ([]byte, error) {
 		args = os.Args[1:]
 	}
 	cmd := exec.CommandContext(ctx, ComDockerCli, args...)
-	return cmd.CombinedOutput()
+	cmd.Stderr = os.Stderr
+	return cmd.Output()
 }

+ 2 - 3
local/e2e/cli-only/e2e_test.go

@@ -397,8 +397,7 @@ func TestLegacy(t *testing.T) {
 	t.Run("host flag", func(t *testing.T) {
 		res := c.RunDockerOrExitError("-H", "tcp://nonexistent:123", "version")
 		assert.Assert(t, res.ExitCode == 1)
-		assert.Assert(t, strings.Contains(res.Stdout(), "dial tcp: lookup nonexistent"), res.Stdout())
-
+		assert.Assert(t, strings.Contains(res.Stderr(), "dial tcp: lookup nonexistent"), res.Stderr())
 	})
 
 	t.Run("remote engine context", func(t *testing.T) {
@@ -407,7 +406,7 @@ func TestLegacy(t *testing.T) {
 
 		res := c.RunDockerOrExitError("version")
 		assert.Assert(t, res.ExitCode == 1)
-		assert.Assert(t, strings.Contains(res.Stdout(), "dial tcp: lookup nonexistent"), res.Stdout())
+		assert.Assert(t, strings.Contains(res.Stderr(), "dial tcp: lookup nonexistent"), res.Stderr())
 	})
 
 	t.Run("existing contexts delegate", func(t *testing.T) {