1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/pipeline/piper.go
Carlos Alexandro Becker 1ed299a6d7 refactor: defaulter interface
Right now the code looks weird because the defaults
of a pipe are far away of the implementation of the pipe.

the intend of this PR is to bring them closer by having a
Defaulter interface.

I also renamed the Pipe interface to Piper, and removed
the Description method in favor for fmt.Stringer.
2017-12-03 13:00:01 -02:00

38 lines
704 B
Go

// Package pipeline provides a generic pipe interface.
package pipeline
import (
"fmt"
"github.com/goreleaser/goreleaser/context"
)
// Piper interface
type Piper interface {
fmt.Stringer
// Run the pipe
Run(ctx *context.Context) error
}
// IsSkip returns true if the error is an ErrSkip
func IsSkip(err error) bool {
_, ok := err.(ErrSkip)
return ok
}
// ErrSkip occurs when a pipe is skipped for some reason
type ErrSkip struct {
reason string
}
// Error implements the error interface. returns the reason the pipe was skipped
func (e ErrSkip) Error() string {
return e.reason
}
// Skip skips this pipe with the given reason
func Skip(reason string) ErrSkip {
return ErrSkip{reason}
}