2016-12-30 09:27:35 -02:00
|
|
|
package pipeline
|
|
|
|
|
2017-12-02 19:53:19 -02:00
|
|
|
import (
|
|
|
|
"fmt"
|
2016-12-30 09:27:35 -02:00
|
|
|
|
2017-12-02 19:53:19 -02:00
|
|
|
"github.com/goreleaser/goreleaser/context"
|
|
|
|
)
|
|
|
|
|
2017-12-03 11:50:51 -02:00
|
|
|
// Piper defines a pipe, which can be part of a pipeline (a serie of pipes).
|
2017-12-02 19:53:19 -02:00
|
|
|
type Piper interface {
|
|
|
|
fmt.Stringer
|
2016-12-30 12:41:59 -02:00
|
|
|
|
|
|
|
// Run the pipe
|
2017-01-14 14:06:57 -02:00
|
|
|
Run(ctx *context.Context) error
|
2016-12-30 09:27:35 -02:00
|
|
|
}
|
2017-08-20 16:35:46 -03:00
|
|
|
|
2018-01-10 19:22:37 -02:00
|
|
|
// ErrSkipPublish happens when skip publish is set and a pipe is refusing
|
|
|
|
// to proceed because of that.
|
|
|
|
var ErrSkipPublish = Skip("--skip-publish is set")
|
|
|
|
|
2017-09-12 00:22:02 -03:00
|
|
|
// IsSkip returns true if the error is an ErrSkip
|
2017-09-11 23:31:00 -03:00
|
|
|
func IsSkip(err error) bool {
|
|
|
|
_, ok := err.(ErrSkip)
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2017-08-20 16:35:46 -03:00
|
|
|
// 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}
|
|
|
|
}
|