From 78b1b9fc438fea40a4c5ccaa703193ae63dcd3d8 Mon Sep 17 00:00:00 2001 From: balopat Date: Fri, 15 May 2020 17:07:51 -0700 Subject: [PATCH] allow error from kind at image loading to propagate --- pkg/skaffold/runner/kind.go | 4 ++-- pkg/skaffold/runner/kind_test.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/skaffold/runner/kind.go b/pkg/skaffold/runner/kind.go index 3e9b93888db..516fac65840 100644 --- a/pkg/skaffold/runner/kind.go +++ b/pkg/skaffold/runner/kind.go @@ -59,9 +59,9 @@ func (r *SkaffoldRunner) loadImagesInKindNodes(ctx context.Context, out io.Write } cmd := exec.CommandContext(ctx, "kind", "load", "docker-image", "--name", kindCluster, artifact.Tag) - if err := util.RunCmd(cmd); err != nil { + if output, err := util.RunCmdOut(cmd); err != nil { color.Red.Fprintln(out, "Failed") - return fmt.Errorf("unable to load image with kind %q: %w", artifact.Tag, err) + return fmt.Errorf("unable to load image with kind %q: %w, %s", artifact.Tag, err, output) } color.Green.Fprintln(out, "Loaded") diff --git a/pkg/skaffold/runner/kind_test.go b/pkg/skaffold/runner/kind_test.go index af9e8de866a..086336b7306 100644 --- a/pkg/skaffold/runner/kind_test.go +++ b/pkg/skaffold/runner/kind_test.go @@ -46,7 +46,7 @@ func TestLoadImagesInKindNodes(t *testing.T) { deployed: []build.Artifact{{Tag: "tag1"}}, commands: testutil. CmdRunOut("kubectl --context kubecontext --namespace namespace get nodes -ojsonpath='{@.items[*].status.images[*].names[*]}'", ""). - AndRun("kind load docker-image --name kind tag1"), + AndRunOut("kind load docker-image --name kind tag1", "output: image loaded"), }, { description: "load missing image", @@ -55,7 +55,7 @@ func TestLoadImagesInKindNodes(t *testing.T) { deployed: []build.Artifact{{Tag: "tag1"}, {Tag: "tag2"}}, commands: testutil. CmdRunOut("kubectl --context kubecontext --namespace namespace get nodes -ojsonpath='{@.items[*].status.images[*].names[*]}'", "tag1"). - AndRun("kind load docker-image --name other-kind tag2"), + AndRunOut("kind load docker-image --name other-kind tag2", "output: image loaded"), }, { description: "inspect error", @@ -73,9 +73,9 @@ func TestLoadImagesInKindNodes(t *testing.T) { deployed: []build.Artifact{{Tag: "tag"}}, commands: testutil. CmdRunOut("kubectl --context kubecontext --namespace namespace get nodes -ojsonpath='{@.items[*].status.images[*].names[*]}'", ""). - AndRunErr("kind load docker-image --name kind tag", errors.New("BUG")), + AndRunOutErr("kind load docker-image --name kind tag", "output: error!", errors.New("BUG")), shouldErr: true, - expectedError: "unable to load", + expectedError: "output: error!", }, { description: "ignore image that's not built", @@ -84,7 +84,7 @@ func TestLoadImagesInKindNodes(t *testing.T) { deployed: []build.Artifact{{Tag: "built"}, {Tag: "busybox"}}, commands: testutil. CmdRunOut("kubectl --context kubecontext --namespace namespace get nodes -ojsonpath='{@.items[*].status.images[*].names[*]}'", ""). - AndRun("kind load docker-image --name kind built"), + AndRunOut("kind load docker-image --name kind built", ""), }, { description: "no artifact",