mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-06 03:13:48 +02:00
refactor: remove unused not impl error (#2540)
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
parent
91eee44ce8
commit
0d4430269b
@ -2,7 +2,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
@ -89,18 +88,3 @@ type RetriableError struct {
|
||||
func (e RetriableError) Error() string {
|
||||
return e.Err.Error()
|
||||
}
|
||||
|
||||
// NotImplementedError happens when trying to use something a client does not
|
||||
// implement.
|
||||
type NotImplementedError struct {
|
||||
TokenType context.TokenType
|
||||
}
|
||||
|
||||
func (e NotImplementedError) Error() string {
|
||||
return fmt.Sprintf("not implemented for %s", e.TokenType)
|
||||
}
|
||||
|
||||
// IsNotImplementedErr returns true if given error is a NotImplementedError.
|
||||
func IsNotImplementedErr(err error) bool {
|
||||
return errors.As(err, &NotImplementedError{})
|
||||
}
|
||||
|
@ -30,15 +30,6 @@ var ErrNoArchivesFound = errors.New("no linux/macos archives found")
|
||||
// for linux or windows.
|
||||
var ErrMultipleArchivesSameOS = errors.New("one tap can handle only archive of an OS/Arch combination. Consider using ids in the brew section")
|
||||
|
||||
// ErrTokenTypeNotImplementedForBrew indicates that a new token type was not implemented for this pipe.
|
||||
type ErrTokenTypeNotImplementedForBrew struct {
|
||||
TokenType context.TokenType
|
||||
}
|
||||
|
||||
func (e ErrTokenTypeNotImplementedForBrew) Error() string {
|
||||
return fmt.Sprintf("token type %q not implemented for brew pipe", e.TokenType)
|
||||
}
|
||||
|
||||
// Pipe for brew deployment.
|
||||
type Pipe struct{}
|
||||
|
||||
@ -293,9 +284,6 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.Client, artifa
|
||||
if cfg.URLTemplate == "" {
|
||||
url, err := cl.ReleaseURLTemplate(ctx)
|
||||
if err != nil {
|
||||
if client.IsNotImplementedErr(err) {
|
||||
return result, ErrTokenTypeNotImplementedForBrew{ctx.TokenType}
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
cfg.URLTemplate = url
|
||||
|
@ -830,42 +830,6 @@ func TestRunEmptyTokenType(t *testing.T) {
|
||||
require.NoError(t, runAll(ctx, client))
|
||||
}
|
||||
|
||||
func TestRunTokenTypeNotImplementedForBrew(t *testing.T) {
|
||||
folder := t.TempDir()
|
||||
ctx := context.New(config.Project{
|
||||
Dist: folder,
|
||||
ProjectName: "foo",
|
||||
Release: config.Release{},
|
||||
Brews: []config.Homebrew{
|
||||
{
|
||||
Tap: config.RepoRef{
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
ctx.TokenType = context.TokenTypeGitea
|
||||
ctx.Git = context.GitInfo{CurrentTag: "v1.0.1"}
|
||||
path := filepath.Join(folder, "whatever.tar.gz")
|
||||
f, err := os.Create(path)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, f.Close())
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Name: "bin",
|
||||
Path: path,
|
||||
Goos: "darwin",
|
||||
Goarch: "amd64",
|
||||
Type: artifact.UploadableArchive,
|
||||
Extra: map[string]interface{}{
|
||||
"ID": "foo",
|
||||
"Format": "tar.gz",
|
||||
},
|
||||
})
|
||||
client := &DummyClient{NotImplemented: true}
|
||||
require.EqualError(t, runAll(ctx, client), `token type "gitea" not implemented for brew pipe`)
|
||||
}
|
||||
|
||||
func TestDefault(t *testing.T) {
|
||||
testlib.Mktmp(t)
|
||||
|
||||
@ -912,9 +876,8 @@ func TestGHFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
type DummyClient struct {
|
||||
CreatedFile bool
|
||||
Content string
|
||||
NotImplemented bool
|
||||
CreatedFile bool
|
||||
Content string
|
||||
}
|
||||
|
||||
func (dc *DummyClient) CloseMilestone(ctx *context.Context, repo client.Repo, title string) error {
|
||||
@ -926,10 +889,6 @@ func (dc *DummyClient) CreateRelease(ctx *context.Context, body string) (release
|
||||
}
|
||||
|
||||
func (dc *DummyClient) ReleaseURLTemplate(ctx *context.Context) (string, error) {
|
||||
if dc.NotImplemented {
|
||||
return "", client.NotImplementedError{}
|
||||
}
|
||||
|
||||
return "https://dummyhost/download/{{ .Tag }}/{{ .ArtifactName }}", nil
|
||||
}
|
||||
|
||||
|
@ -28,15 +28,6 @@ var ErrNoArchivesFound = errors.New("no linux/macos/windows archives found")
|
||||
|
||||
var ErrMultipleArchivesSameOS = errors.New("one rig can handle only archive of an OS/Arch combination. Consider using ids in the gofish section")
|
||||
|
||||
// ErrTokenTypeNotImplementedForGoFish indicates that a new token type was not implemented for this pipe.
|
||||
type ErrTokenTypeNotImplementedForGoFish struct {
|
||||
TokenType context.TokenType
|
||||
}
|
||||
|
||||
func (e ErrTokenTypeNotImplementedForGoFish) Error() string {
|
||||
return fmt.Sprintf("token type %q not implemented for gofish pipe", e.TokenType)
|
||||
}
|
||||
|
||||
// Pipe for goFish deployment.
|
||||
type Pipe struct{}
|
||||
|
||||
@ -207,9 +198,6 @@ func dataFor(ctx *context.Context, cfg config.GoFish, cl client.Client, artifact
|
||||
if cfg.URLTemplate == "" {
|
||||
url, err := cl.ReleaseURLTemplate(ctx)
|
||||
if err != nil {
|
||||
if client.IsNotImplementedErr(err) {
|
||||
return result, ErrTokenTypeNotImplementedForGoFish{ctx.TokenType}
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
cfg.URLTemplate = url
|
||||
@ -245,8 +233,6 @@ func (Pipe) Publish(ctx *context.Context) error {
|
||||
}
|
||||
|
||||
func publishAll(ctx *context.Context, cli client.Client) error {
|
||||
// even if one of them skips, we run them all, and then show return the skips all at once.
|
||||
// this is needed so we actually create the `dist/foo.lua` file, which is useful for debugging.
|
||||
skips := pipe.SkipMemento{}
|
||||
for _, rig := range ctx.Artifacts.Filter(artifact.ByType(artifact.GoFishRig)).List() {
|
||||
err := doPublish(ctx, rig, cli)
|
||||
|
@ -761,42 +761,6 @@ func TestRunEmptyTokenType(t *testing.T) {
|
||||
require.NoError(t, runAll(ctx, client))
|
||||
}
|
||||
|
||||
func TestRunTokenTypeNotImplementedForGoFish(t *testing.T) {
|
||||
folder := t.TempDir()
|
||||
ctx := context.New(config.Project{
|
||||
Dist: folder,
|
||||
ProjectName: "foo",
|
||||
Release: config.Release{},
|
||||
Rigs: []config.GoFish{
|
||||
{
|
||||
Rig: config.RepoRef{
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
ctx.TokenType = context.TokenTypeGitea
|
||||
ctx.Git = context.GitInfo{CurrentTag: "v1.0.1"}
|
||||
path := filepath.Join(folder, "whatever.tar.gz")
|
||||
f, err := os.Create(path)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, f.Close())
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Name: "bin",
|
||||
Path: path,
|
||||
Goos: "darwin",
|
||||
Goarch: "amd64",
|
||||
Type: artifact.UploadableArchive,
|
||||
Extra: map[string]interface{}{
|
||||
"ID": "foo",
|
||||
"Format": "tar.gz",
|
||||
},
|
||||
})
|
||||
client := &DummyClient{NotImplemented: true}
|
||||
require.EqualError(t, runAll(ctx, client), `token type "gitea" not implemented for gofish pipe`)
|
||||
}
|
||||
|
||||
func TestDefault(t *testing.T) {
|
||||
testlib.Mktmp(t)
|
||||
|
||||
@ -842,9 +806,8 @@ func TestGHFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
type DummyClient struct {
|
||||
CreatedFile bool
|
||||
Content string
|
||||
NotImplemented bool
|
||||
CreatedFile bool
|
||||
Content string
|
||||
}
|
||||
|
||||
func (dc *DummyClient) CloseMilestone(ctx *context.Context, repo client.Repo, title string) error {
|
||||
@ -856,10 +819,6 @@ func (dc *DummyClient) CreateRelease(ctx *context.Context, body string) (release
|
||||
}
|
||||
|
||||
func (dc *DummyClient) ReleaseURLTemplate(ctx *context.Context) (string, error) {
|
||||
if dc.NotImplemented {
|
||||
return "", client.NotImplementedError{}
|
||||
}
|
||||
|
||||
return "https://dummyhost/download/{{ .Tag }}/{{ .ArtifactName }}", nil
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,6 @@ import (
|
||||
// ErrNoWindows when there is no build for windows (goos doesn't contain windows).
|
||||
var ErrNoWindows = errors.New("scoop requires a windows build")
|
||||
|
||||
// ErrTokenTypeNotImplementedForScoop indicates that a new token type was not implemented for this pipe.
|
||||
var ErrTokenTypeNotImplementedForScoop = errors.New("token type not implemented for scoop pipe")
|
||||
|
||||
const scoopConfigExtra = "ScoopConfig"
|
||||
|
||||
// Pipe that builds and publishes scoop manifests.
|
||||
@ -209,9 +206,6 @@ func dataFor(ctx *context.Context, cl client.Client, artifacts []*artifact.Artif
|
||||
if ctx.Config.Scoop.URLTemplate == "" {
|
||||
url, err := cl.ReleaseURLTemplate(ctx)
|
||||
if err != nil {
|
||||
if client.IsNotImplementedErr(err) {
|
||||
return manifest, ErrTokenTypeNotImplementedForScoop
|
||||
}
|
||||
return manifest, err
|
||||
}
|
||||
ctx.Config.Scoop.URLTemplate = url
|
||||
|
@ -360,50 +360,6 @@ func Test_doRun(t *testing.T) {
|
||||
shouldNotErr,
|
||||
noAssertions,
|
||||
},
|
||||
{
|
||||
"token type not implemented for pipe",
|
||||
args{
|
||||
&context.Context{
|
||||
Git: context.GitInfo{
|
||||
CurrentTag: "v1.0.1",
|
||||
},
|
||||
Version: "1.0.1",
|
||||
Artifacts: artifact.New(),
|
||||
Config: config.Project{
|
||||
Builds: []config.Build{
|
||||
{Binary: "test", Goarch: []string{"amd64"}, Goos: []string{"windows"}},
|
||||
},
|
||||
Dist: ".",
|
||||
ProjectName: "run-pipe",
|
||||
Archives: []config.Archive{
|
||||
{Format: "tar.gz"},
|
||||
},
|
||||
Release: config.Release{
|
||||
GitHub: config.Repo{
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
},
|
||||
},
|
||||
Scoop: config.Scoop{
|
||||
Bucket: config.RepoRef{
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
},
|
||||
Description: "A run pipe test formula",
|
||||
Homepage: "https://github.com/goreleaser",
|
||||
},
|
||||
},
|
||||
},
|
||||
&DummyClient{NotImplemented: true},
|
||||
},
|
||||
[]*artifact.Artifact{
|
||||
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Path: file},
|
||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
||||
},
|
||||
shouldErr(ErrTokenTypeNotImplementedForScoop.Error()),
|
||||
shouldNotErr,
|
||||
noAssertions,
|
||||
},
|
||||
{
|
||||
"no windows build",
|
||||
args{
|
||||
@ -1081,10 +1037,9 @@ func TestSkip(t *testing.T) {
|
||||
}
|
||||
|
||||
type DummyClient struct {
|
||||
CreatedFile bool
|
||||
Content string
|
||||
Path string
|
||||
NotImplemented bool
|
||||
CreatedFile bool
|
||||
Content string
|
||||
Path string
|
||||
}
|
||||
|
||||
func (dc *DummyClient) CloseMilestone(ctx *context.Context, repo client.Repo, title string) error {
|
||||
@ -1096,9 +1051,6 @@ func (dc *DummyClient) CreateRelease(ctx *context.Context, body string) (release
|
||||
}
|
||||
|
||||
func (dc *DummyClient) ReleaseURLTemplate(ctx *context.Context) (string, error) {
|
||||
if dc.NotImplemented {
|
||||
return "", client.NotImplementedError{}
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user