From 8b73d1f8d0932f71d64961a7ac69caa3a0e60552 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Sat, 12 Jan 2019 11:32:39 +0100 Subject: [PATCH] Use cmd.Run() indirection Signed-off-by: David Gageot --- pkg/skaffold/build/local/bazel.go | 2 +- pkg/skaffold/kubernetes/log.go | 3 ++- pkg/skaffold/kubernetes/port_forward.go | 2 +- pkg/skaffold/test/structure/structure.go | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/skaffold/build/local/bazel.go b/pkg/skaffold/build/local/bazel.go index 0717a8e6baa..47ee8dc093d 100644 --- a/pkg/skaffold/build/local/bazel.go +++ b/pkg/skaffold/build/local/bazel.go @@ -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") } diff --git a/pkg/skaffold/kubernetes/log.go b/pkg/skaffold/kubernetes/log.go index 469789d978b..2d95a41d351 100644 --- a/pkg/skaffold/kubernetes/log.go +++ b/pkg/skaffold/kubernetes/log.go @@ -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 @@ -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) diff --git a/pkg/skaffold/kubernetes/port_forward.go b/pkg/skaffold/kubernetes/port_forward.go index 489a4419295..7728be855e9 100644 --- a/pkg/skaffold/kubernetes/port_forward.go +++ b/pkg/skaffold/kubernetes/port_forward.go @@ -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 diff --git a/pkg/skaffold/test/structure/structure.go b/pkg/skaffold/test/structure/structure.go index 63f226459c3..ba01f4c25e9 100644 --- a/pkg/skaffold/test/structure/structure.go +++ b/pkg/skaffold/test/structure/structure.go @@ -21,6 +21,7 @@ import ( "io" "os/exec" + "github.com/GoogleContainerTools/skaffold/pkg/skaffold/util" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -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") }