1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

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.
This commit is contained in:
Carlos Alexandro Becker 2018-07-17 08:24:58 -03:00 committed by GitHub
parent ee706ae502
commit ce83c85bfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -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()

View File

@ -314,7 +314,7 @@ func TestRunPipe(t *testing.T) {
Dockerfile: "testdata/Dockerfile",
},
},
assertError: shouldNotErr,
assertError: shouldErr(`0 binaries match docker definition: mybinnnn: darwin_amd64_`),
},
}