Skip to content

Commit

Permalink
Merge pull request #1457 from dgageot/use-cmd-indirection
Browse files Browse the repository at this point in the history
Use cmd.Run() indirection
  • Loading branch information
dgageot authored Jan 14, 2019
2 parents e54cbdf + 8b73d1f commit 40c6426
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/skaffold/build/local/bazel.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (b *Builder) buildBazel(ctx context.Context, out io.Writer, workspace strin
cmd.Dir = workspace
cmd.Stdout = out
cmd.Stderr = out
if err := cmd.Run(); err != nil {
if err := util.RunCmd(cmd); err != nil {
return "", errors.Wrap(err, "running command")
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/skaffold/kubernetes/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"k8s.io/apimachinery/pkg/watch"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
)

// Client is for tests
Expand Down Expand Up @@ -146,7 +147,7 @@ func (a *LogAggregator) streamContainerLogs(ctx context.Context, pod *v1.Pod, co
tr, tw := io.Pipe()
cmd := exec.CommandContext(ctx, "kubectl", "logs", sinceSeconds, "-f", pod.Name, "-c", container.Name, "--namespace", pod.Namespace)
cmd.Stdout = tw
go cmd.Run()
go util.RunCmd(cmd)

color := a.colorPicker.Pick(pod)
prefix := prefix(pod, container)
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/kubernetes/port_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (*kubectlForwarder) Forward(pfe *portForwardEntry) error {
cmd.Stdout = buf
cmd.Stderr = buf

if err := cmd.Run(); err != nil && !util.IsTerminatedError(err) {
if err := util.RunCmd(cmd); err != nil && !util.IsTerminatedError(err) {
return errors.Wrapf(err, "port forwarding pod: %s/%s, port: %s, err: %s", pfe.namespace, pfe.podName, portNumber, buf.String())
}
return nil
Expand Down
3 changes: 2 additions & 1 deletion pkg/skaffold/test/structure/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io"
"os/exec"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
Expand All @@ -38,7 +39,7 @@ func (tr *Runner) Test(ctx context.Context, out io.Writer, image string) error {
cmd.Stdout = out
cmd.Stderr = out

if err := cmd.Run(); err != nil {
if err := util.RunCmd(cmd); err != nil {
return errors.Wrap(err, "running container-structure-test")
}

Expand Down

0 comments on commit 40c6426

Please sign in to comment.