1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-09-16 09:26:52 +02:00
This commit is contained in:
Carlos Alexandro Becker
2017-09-12 00:22:02 -03:00
parent 2ce8589587
commit 4c4b9ef42c
3 changed files with 18 additions and 3 deletions

View File

@@ -14,7 +14,10 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// Pipe for checksums // ErrNoDocker is shown when docker cannot be found in $PATH
var ErrNoDocker = errors.New("docker not present in $PATH")
// Pipe for docker
type Pipe struct{} type Pipe struct{}
// Description of the pipe // Description of the pipe
@@ -23,13 +26,17 @@ func (Pipe) Description() string {
} }
// Run the pipe // Run the pipe
func (Pipe) Run(ctx *context.Context) (err error) { func (Pipe) Run(ctx *context.Context) error {
if ctx.Config.Dockers[0].Image == "" { if len(ctx.Config.Dockers) == 0 || ctx.Config.Dockers[0].Image == "" {
return pipeline.Skip("docker section is not configured") return pipeline.Skip("docker section is not configured")
} }
if ctx.Config.Release.Draft { if ctx.Config.Release.Draft {
return pipeline.Skip("release is marked as draft") return pipeline.Skip("release is marked as draft")
} }
_, err := exec.LookPath("docker")
if err != nil {
return ErrNoDocker
}
for _, docker := range ctx.Config.Dockers { for _, docker := range ctx.Config.Dockers {
var imagePlatform = docker.Goos + docker.Goarch + docker.Goarm var imagePlatform = docker.Goos + docker.Goarch + docker.Goarm
for platform, groups := range ctx.Binaries { for platform, groups := range ctx.Binaries {

View File

@@ -12,6 +12,7 @@ type Pipe interface {
Run(ctx *context.Context) error Run(ctx *context.Context) error
} }
// IsSkip returns true if the error is an ErrSkip
func IsSkip(err error) bool { func IsSkip(err error) bool {
_, ok := err.(ErrSkip) _, ok := err.(ErrSkip)
return ok return ok

View File

@@ -1,6 +1,7 @@
package pipeline package pipeline
import ( import (
"errors"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@@ -13,3 +14,9 @@ func TestSkipPipe(t *testing.T) {
assert.Error(err) assert.Error(err)
assert.Equal(reason, err.Error()) assert.Equal(reason, err.Error())
} }
func TestIsSkip(t *testing.T) {
var assert = assert.New(t)
assert.True(IsSkip(Skip("whatever")))
assert.False(IsSkip(errors.New("nope")))
}