Skip to content

Commit 824f170

Browse files
authored
Do not marshal docker command to JSON when logging (#364)
With the command being in JSON it's really hard to copy and run it to debug something. And since we don't ever need this output in JSON, I changed the code to log log the un-rendered version of run.Step and then the full command.
1 parent 6da1a99 commit 824f170

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

internal/campaigns/run_steps.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package campaigns
33
import (
44
"bytes"
55
"context"
6-
"encoding/json"
76
"fmt"
87
"io"
98
"io/ioutil"
@@ -64,8 +63,6 @@ func runSteps(ctx context.Context, wc *WorkspaceCreator, repo *graphql.Repositor
6463
results := make([]StepResult, len(steps))
6564

6665
for i, step := range steps {
67-
logger.Logf("[Step %d] docker run %s %q", i+1, step.Container, step.Run)
68-
6966
stepContext := StepContext{Repository: *repo}
7067
if i > 0 {
7168
stepContext.PreviousStep = results[i-1]
@@ -176,11 +173,8 @@ func runSteps(ctx context.Context, wc *WorkspaceCreator, repo *graphql.Repositor
176173
cmd.Stdout = io.MultiWriter(&stdoutBuffer, logger.PrefixWriter("stdout"))
177174
cmd.Stderr = io.MultiWriter(&stderrBuffer, logger.PrefixWriter("stderr"))
178175

179-
a, err := json.Marshal(cmd.Args)
180-
if err != nil {
181-
panic(err)
182-
}
183-
logger.Log(string(a))
176+
logger.Logf("[Step %d] run: %q, container: %q", i+1, step.Run, step.Container)
177+
logger.Logf("[Step %d] full command: %q", i+1, strings.Join(cmd.Args, " "))
184178

185179
t0 := time.Now()
186180
err = cmd.Run()

0 commit comments

Comments
 (0)