Skip to content

Commit

Permalink
refactor: pipe.Skipf
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Mar 23, 2023
1 parent ede2ff9 commit 7229a0d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func getPassword(ctx *context.Context, upload *config.Upload, kind string) strin
}

func misconfigured(kind string, upload *config.Upload, reason string) error {
return pipe.Skip(fmt.Sprintf("%s section '%s' is not configured properly (%s)", kind, upload.Name, reason))
return pipe.Skipf("%s section '%s' is not configured properly (%s)", kind, upload.Name, reason)
}

// ResponseChecker is a function capable of validating an http server response.
Expand Down
6 changes: 6 additions & 0 deletions internal/pipe/pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pipe

import (
"errors"
"fmt"
"strings"
)

Expand Down Expand Up @@ -45,6 +46,11 @@ func Skip(reason string) ErrSkip {
return ErrSkip{reason: reason}
}

// Skipf skips this pipe with the given reason.
func Skipf(format string, a ...any) ErrSkip {
return Skip(fmt.Sprintf(format, a...))
}

// SkipMemento remembers previous skip errors so you can return them all at once later.
type SkipMemento struct {
skips []string
Expand Down
2 changes: 1 addition & 1 deletion internal/pipe/universalbinary/universalbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func makeUniversalBinary(ctx *context.Context, opts *build.Options, unibin confi

binaries := ctx.Artifacts.Filter(filterFor(unibin)).List()
if len(binaries) == 0 {
return pipe.Skip(fmt.Sprintf("no darwin binaries found with id %q", unibin.ID))
return pipe.Skipf("no darwin binaries found with id %q", unibin.ID)
}

log.WithField("id", unibin.ID).
Expand Down

0 comments on commit 7229a0d

Please sign in to comment.