1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/internal/pipe/pipe.go
dependabot[bot] 27aa6871cb
chore(deps): bump github.com/golangci/golangci-lint from 1.31.0 to 1.32.2 (#1882)
* chore(deps): bump github.com/golangci/golangci-lint

Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.31.0 to 1.32.2.
- [Release notes](https://github.com/golangci/golangci-lint/releases)
- [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/golangci/golangci-lint/compare/v1.31.0...v1.32.2)

Signed-off-by: dependabot[bot] <support@github.com>

* fix: lint issues

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* refactor: lint issues

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2020-11-10 11:15:03 -03:00

67 lines
1.9 KiB
Go

// Package pipe provides generic erros for pipes to use.
package pipe
import (
"errors"
"strings"
)
// ErrSnapshotEnabled happens when goreleaser is running in snapshot mode.
// It usually means that publishing and maybe some validations were skipped.
var ErrSnapshotEnabled = Skip("disabled during snapshot mode")
// ErrSkipPublishEnabled happens if --skip-publish is set.
// It means that the part of a Piper that publishes its artifacts was not run.
var ErrSkipPublishEnabled = Skip("publishing is disabled")
// ErrSkipSignEnabled happens if --skip-sign is set.
// It means that the part of a Piper that signs some things was not run.
var ErrSkipSignEnabled = Skip("artifact signing is disabled")
// ErrSkipValidateEnabled happens if --skip-validate is set.
// It means that the part of a Piper that validates some things was not run.
var ErrSkipValidateEnabled = Skip("validation is disabled")
// IsSkip returns true if the error is an ErrSkip.
func IsSkip(err error) bool {
return errors.As(err, &ErrSkip{})
}
// 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: reason}
}
// SkipMemento remembers previous skip errors so you can return them all at once later.
type SkipMemento struct {
skips []string
}
// Remember a skip.
func (e *SkipMemento) Remember(err error) {
for _, skip := range e.skips {
if skip == err.Error() {
return
}
}
e.skips = append(e.skips, err.Error())
}
// Evaluate return a skip error with all previous skips, or nil if none happened.
func (e *SkipMemento) Evaluate() error {
if len(e.skips) == 0 {
return nil
}
return Skip(strings.Join(e.skips, ", "))
}