You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-17 01:42:37 +02:00
refactor: remove unused not impl error (#2540)
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
committed by
GitHub
parent
91eee44ce8
commit
0d4430269b
@ -2,7 +2,6 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -89,18 +88,3 @@ type RetriableError struct {
|
|||||||
func (e RetriableError) Error() string {
|
func (e RetriableError) Error() string {
|
||||||
return e.Err.Error()
|
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.
|
// 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")
|
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.
|
// Pipe for brew deployment.
|
||||||
type Pipe struct{}
|
type Pipe struct{}
|
||||||
|
|
||||||
@ -293,9 +284,6 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.Client, artifa
|
|||||||
if cfg.URLTemplate == "" {
|
if cfg.URLTemplate == "" {
|
||||||
url, err := cl.ReleaseURLTemplate(ctx)
|
url, err := cl.ReleaseURLTemplate(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if client.IsNotImplementedErr(err) {
|
|
||||||
return result, ErrTokenTypeNotImplementedForBrew{ctx.TokenType}
|
|
||||||
}
|
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
cfg.URLTemplate = url
|
cfg.URLTemplate = url
|
||||||
|
@ -830,42 +830,6 @@ func TestRunEmptyTokenType(t *testing.T) {
|
|||||||
require.NoError(t, runAll(ctx, client))
|
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) {
|
func TestDefault(t *testing.T) {
|
||||||
testlib.Mktmp(t)
|
testlib.Mktmp(t)
|
||||||
|
|
||||||
@ -914,7 +878,6 @@ func TestGHFolder(t *testing.T) {
|
|||||||
type DummyClient struct {
|
type DummyClient struct {
|
||||||
CreatedFile bool
|
CreatedFile bool
|
||||||
Content string
|
Content string
|
||||||
NotImplemented bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *DummyClient) CloseMilestone(ctx *context.Context, repo client.Repo, title string) error {
|
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) {
|
func (dc *DummyClient) ReleaseURLTemplate(ctx *context.Context) (string, error) {
|
||||||
if dc.NotImplemented {
|
|
||||||
return "", client.NotImplementedError{}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "https://dummyhost/download/{{ .Tag }}/{{ .ArtifactName }}", nil
|
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")
|
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.
|
// Pipe for goFish deployment.
|
||||||
type Pipe struct{}
|
type Pipe struct{}
|
||||||
|
|
||||||
@ -207,9 +198,6 @@ func dataFor(ctx *context.Context, cfg config.GoFish, cl client.Client, artifact
|
|||||||
if cfg.URLTemplate == "" {
|
if cfg.URLTemplate == "" {
|
||||||
url, err := cl.ReleaseURLTemplate(ctx)
|
url, err := cl.ReleaseURLTemplate(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if client.IsNotImplementedErr(err) {
|
|
||||||
return result, ErrTokenTypeNotImplementedForGoFish{ctx.TokenType}
|
|
||||||
}
|
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
cfg.URLTemplate = url
|
cfg.URLTemplate = url
|
||||||
@ -245,8 +233,6 @@ func (Pipe) Publish(ctx *context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func publishAll(ctx *context.Context, cli client.Client) 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{}
|
skips := pipe.SkipMemento{}
|
||||||
for _, rig := range ctx.Artifacts.Filter(artifact.ByType(artifact.GoFishRig)).List() {
|
for _, rig := range ctx.Artifacts.Filter(artifact.ByType(artifact.GoFishRig)).List() {
|
||||||
err := doPublish(ctx, rig, cli)
|
err := doPublish(ctx, rig, cli)
|
||||||
|
@ -761,42 +761,6 @@ func TestRunEmptyTokenType(t *testing.T) {
|
|||||||
require.NoError(t, runAll(ctx, client))
|
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) {
|
func TestDefault(t *testing.T) {
|
||||||
testlib.Mktmp(t)
|
testlib.Mktmp(t)
|
||||||
|
|
||||||
@ -844,7 +808,6 @@ func TestGHFolder(t *testing.T) {
|
|||||||
type DummyClient struct {
|
type DummyClient struct {
|
||||||
CreatedFile bool
|
CreatedFile bool
|
||||||
Content string
|
Content string
|
||||||
NotImplemented bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *DummyClient) CloseMilestone(ctx *context.Context, repo client.Repo, title string) error {
|
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) {
|
func (dc *DummyClient) ReleaseURLTemplate(ctx *context.Context) (string, error) {
|
||||||
if dc.NotImplemented {
|
|
||||||
return "", client.NotImplementedError{}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "https://dummyhost/download/{{ .Tag }}/{{ .ArtifactName }}", nil
|
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).
|
// ErrNoWindows when there is no build for windows (goos doesn't contain windows).
|
||||||
var ErrNoWindows = errors.New("scoop requires a windows build")
|
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"
|
const scoopConfigExtra = "ScoopConfig"
|
||||||
|
|
||||||
// Pipe that builds and publishes scoop manifests.
|
// 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 == "" {
|
if ctx.Config.Scoop.URLTemplate == "" {
|
||||||
url, err := cl.ReleaseURLTemplate(ctx)
|
url, err := cl.ReleaseURLTemplate(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if client.IsNotImplementedErr(err) {
|
|
||||||
return manifest, ErrTokenTypeNotImplementedForScoop
|
|
||||||
}
|
|
||||||
return manifest, err
|
return manifest, err
|
||||||
}
|
}
|
||||||
ctx.Config.Scoop.URLTemplate = url
|
ctx.Config.Scoop.URLTemplate = url
|
||||||
|
@ -360,50 +360,6 @@ func Test_doRun(t *testing.T) {
|
|||||||
shouldNotErr,
|
shouldNotErr,
|
||||||
noAssertions,
|
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",
|
"no windows build",
|
||||||
args{
|
args{
|
||||||
@ -1084,7 +1040,6 @@ type DummyClient struct {
|
|||||||
CreatedFile bool
|
CreatedFile bool
|
||||||
Content string
|
Content string
|
||||||
Path string
|
Path string
|
||||||
NotImplemented bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *DummyClient) CloseMilestone(ctx *context.Context, repo client.Repo, title string) error {
|
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) {
|
func (dc *DummyClient) ReleaseURLTemplate(ctx *context.Context) (string, error) {
|
||||||
if dc.NotImplemented {
|
|
||||||
return "", client.NotImplementedError{}
|
|
||||||
}
|
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user