From ce83c85bfc74fd5551f89e4e8aff6dd28264a31b Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 17 Jul 2018 08:24:58 -0300 Subject: [PATCH] fix: improve docker error handling (#726) improved the case in which a docker image may be declared but have no binaries matching it (which can really happen) and the case of a binary + goos + goarch + goarm combination matching more than one binary (can't happen right now). Later it will just warn on the first case and do things wrong on the second, now it will error in both cases. --- pipeline/docker/docker.go | 15 +++++++-------- pipeline/docker/docker_test.go | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pipeline/docker/docker.go b/pipeline/docker/docker.go index 9bb70a4cd..6a21dc266 100644 --- a/pipeline/docker/docker.go +++ b/pipeline/docker/docker.go @@ -95,15 +95,14 @@ func doRun(ctx *context.Context) error { }, ), ).List() - if len(binaries) == 0 { - log.Warnf("no binaries found for %s", docker.Binary) + if len(binaries) != 1 { + return fmt.Errorf( + "%d binaries match docker definition: %s: %s_%s_%s", + len(binaries), + docker.Binary, docker.Goos, docker.Goarch, docker.Goarm, + ) } - for _, binary := range binaries { - if err := process(ctx, docker, binary, seed); err != nil { - return err - } - } - return nil + return process(ctx, docker, binaries[0], seed) }) } return g.Wait() diff --git a/pipeline/docker/docker_test.go b/pipeline/docker/docker_test.go index 1282e06b8..40470bb7e 100644 --- a/pipeline/docker/docker_test.go +++ b/pipeline/docker/docker_test.go @@ -314,7 +314,7 @@ func TestRunPipe(t *testing.T) { Dockerfile: "testdata/Dockerfile", }, }, - assertError: shouldNotErr, + assertError: shouldErr(`0 binaries match docker definition: mybinnnn: darwin_amd64_`), }, }