mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-09 13:36:56 +02:00
refactor: artifactory: pipe -> publisher
This commit is contained in:
parent
ad11351902
commit
2bade44c73
@ -51,10 +51,10 @@ func (Pipe) Default(ctx *context.Context) error {
|
||||
return http.Defaults(ctx.Config.Artifactories)
|
||||
}
|
||||
|
||||
// Run the pipe
|
||||
// Publish artifacts to artifactory
|
||||
//
|
||||
// Docs: https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-Example-DeployinganArtifact
|
||||
func (Pipe) Run(ctx *context.Context) error {
|
||||
func (Pipe) Publish(ctx *context.Context) error {
|
||||
if len(ctx.Config.Artifactories) == 0 {
|
||||
return pipe.Skip("artifactory section is not configured")
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ func TestRunPipe_ModeBinary(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
assert.NoError(t, Pipe{}.Run(ctx))
|
||||
assert.NoError(t, Pipe{}.Publish(ctx))
|
||||
}
|
||||
|
||||
func TestRunPipe_ModeArchive(t *testing.T) {
|
||||
@ -300,7 +300,7 @@ func TestRunPipe_ModeArchive(t *testing.T) {
|
||||
uploads.Store("deb", true)
|
||||
})
|
||||
|
||||
assert.NoError(t, Pipe{}.Run(ctx))
|
||||
assert.NoError(t, Pipe{}.Publish(ctx))
|
||||
_, ok := uploads.Load("targz")
|
||||
assert.True(t, ok, "tar.gz file was not uploaded")
|
||||
_, ok = uploads.Load("deb")
|
||||
@ -334,7 +334,7 @@ func TestRunPipe_ArtifactoryDown(t *testing.T) {
|
||||
Name: "bin.tar.gz",
|
||||
Path: tarfile.Name(),
|
||||
})
|
||||
err = Pipe{}.Run(ctx)
|
||||
err = Pipe{}.Publish(ctx)
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "connection refused")
|
||||
}
|
||||
@ -369,7 +369,7 @@ func TestRunPipe_TargetTemplateError(t *testing.T) {
|
||||
Type: artifact.UploadableBinary,
|
||||
})
|
||||
|
||||
assert.EqualError(t, Pipe{}.Run(ctx), `artifactory: error while building the target url: template: mybin:1: unexpected "/" in operand`)
|
||||
assert.EqualError(t, Pipe{}.Publish(ctx), `artifactory: error while building the target url: template: mybin:1: unexpected "/" in operand`)
|
||||
}
|
||||
|
||||
func TestRunPipe_BadCredentials(t *testing.T) {
|
||||
@ -425,7 +425,7 @@ func TestRunPipe_BadCredentials(t *testing.T) {
|
||||
Type: artifact.UploadableBinary,
|
||||
})
|
||||
|
||||
err = Pipe{}.Run(ctx)
|
||||
err = Pipe{}.Publish(ctx)
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "Bad credentials")
|
||||
}
|
||||
@ -482,7 +482,7 @@ func TestRunPipe_UnparsableErrorResponse(t *testing.T) {
|
||||
Type: artifact.UploadableBinary,
|
||||
})
|
||||
|
||||
assert.EqualError(t, Pipe{}.Run(ctx), `artifactory: upload failed: invalid character '.' looking for beginning of value`)
|
||||
assert.EqualError(t, Pipe{}.Publish(ctx), `artifactory: upload failed: invalid character '.' looking for beginning of value`)
|
||||
}
|
||||
|
||||
func TestRunPipe_UnparsableResponse(t *testing.T) {
|
||||
@ -536,7 +536,7 @@ func TestRunPipe_UnparsableResponse(t *testing.T) {
|
||||
Type: artifact.UploadableBinary,
|
||||
})
|
||||
|
||||
assert.EqualError(t, Pipe{}.Run(ctx), `artifactory: upload failed: invalid character 'i' looking for beginning of value`)
|
||||
assert.EqualError(t, Pipe{}.Publish(ctx), `artifactory: upload failed: invalid character 'i' looking for beginning of value`)
|
||||
}
|
||||
|
||||
func TestRunPipe_FileNotFound(t *testing.T) {
|
||||
@ -563,7 +563,7 @@ func TestRunPipe_FileNotFound(t *testing.T) {
|
||||
Type: artifact.UploadableBinary,
|
||||
})
|
||||
|
||||
assert.EqualError(t, Pipe{}.Run(ctx), `open archivetest/dist/mybin/mybin: no such file or directory`)
|
||||
assert.EqualError(t, Pipe{}.Publish(ctx), `open archivetest/dist/mybin/mybin: no such file or directory`)
|
||||
}
|
||||
|
||||
func TestRunPipe_UnparsableTarget(t *testing.T) {
|
||||
@ -600,7 +600,7 @@ func TestRunPipe_UnparsableTarget(t *testing.T) {
|
||||
Type: artifact.UploadableBinary,
|
||||
})
|
||||
|
||||
assert.EqualError(t, Pipe{}.Run(ctx), `artifactory: upload failed: parse ://artifacts.company.com/example-repo-local/mybin/darwin/amd64/mybin: missing protocol scheme`)
|
||||
assert.EqualError(t, Pipe{}.Publish(ctx), `artifactory: upload failed: parse ://artifacts.company.com/example-repo-local/mybin/darwin/amd64/mybin: missing protocol scheme`)
|
||||
}
|
||||
|
||||
func TestRunPipe_SkipWhenPublishFalse(t *testing.T) {
|
||||
@ -619,7 +619,7 @@ func TestRunPipe_SkipWhenPublishFalse(t *testing.T) {
|
||||
}
|
||||
ctx.SkipPublish = true
|
||||
|
||||
err := Pipe{}.Run(ctx)
|
||||
err := Pipe{}.Publish(ctx)
|
||||
assert.True(t, pipe.IsSkip(err))
|
||||
assert.EqualError(t, err, pipe.ErrSkipPublishEnabled.Error())
|
||||
}
|
||||
@ -655,7 +655,7 @@ func TestRunPipe_DirUpload(t *testing.T) {
|
||||
Type: artifact.UploadableBinary,
|
||||
})
|
||||
|
||||
assert.EqualError(t, Pipe{}.Run(ctx), `artifactory: upload failed: the asset to upload can't be a directory`)
|
||||
assert.EqualError(t, Pipe{}.Publish(ctx), `artifactory: upload failed: the asset to upload can't be a directory`)
|
||||
}
|
||||
|
||||
func TestDescription(t *testing.T) {
|
||||
@ -663,7 +663,7 @@ func TestDescription(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNoArtifactories(t *testing.T) {
|
||||
assert.True(t, pipe.IsSkip(Pipe{}.Run(context.New(config.Project{}))))
|
||||
assert.True(t, pipe.IsSkip(Pipe{}.Publish(context.New(config.Project{}))))
|
||||
}
|
||||
|
||||
func TestArtifactoriesWithoutTarget(t *testing.T) {
|
||||
@ -681,7 +681,7 @@ func TestArtifactoriesWithoutTarget(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.True(t, pipe.IsSkip(Pipe{}.Run(ctx)))
|
||||
assert.True(t, pipe.IsSkip(Pipe{}.Publish(ctx)))
|
||||
}
|
||||
|
||||
func TestArtifactoriesWithoutUsername(t *testing.T) {
|
||||
@ -699,11 +699,11 @@ func TestArtifactoriesWithoutUsername(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.True(t, pipe.IsSkip(Pipe{}.Run(ctx)))
|
||||
assert.True(t, pipe.IsSkip(Pipe{}.Publish(ctx)))
|
||||
}
|
||||
|
||||
func TestArtifactoriesWithoutName(t *testing.T) {
|
||||
assert.True(t, pipe.IsSkip(Pipe{}.Run(context.New(config.Project{
|
||||
assert.True(t, pipe.IsSkip(Pipe{}.Publish(context.New(config.Project{
|
||||
Artifactories: []config.Put{
|
||||
{
|
||||
Username: "deployuser",
|
||||
@ -714,7 +714,7 @@ func TestArtifactoriesWithoutName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestArtifactoriesWithoutSecret(t *testing.T) {
|
||||
assert.True(t, pipe.IsSkip(Pipe{}.Run(context.New(config.Project{
|
||||
assert.True(t, pipe.IsSkip(Pipe{}.Publish(context.New(config.Project{
|
||||
Artifactories: []config.Put{
|
||||
{
|
||||
Name: "production",
|
||||
@ -741,7 +741,7 @@ func TestArtifactoriesWithInvalidMode(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
assert.Error(t, Pipe{}.Run(ctx))
|
||||
assert.Error(t, Pipe{}.Publish(ctx))
|
||||
}
|
||||
|
||||
func TestDefault(t *testing.T) {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"github.com/apex/log"
|
||||
"github.com/fatih/color"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/artifactory"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/brew"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/put"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/release"
|
||||
@ -34,6 +35,7 @@ type Publisher interface {
|
||||
var publishers = []Publisher{
|
||||
s3.Pipe{},
|
||||
put.Pipe{},
|
||||
artifactory.Pipe{},
|
||||
release.Pipe{},
|
||||
brew.Pipe{},
|
||||
scoop.Pipe{},
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/archive"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/artifactory"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/before"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/build"
|
||||
"github.com/goreleaser/goreleaser/internal/pipe/changelog"
|
||||
@ -47,6 +46,5 @@ var Pipeline = []Piper{
|
||||
checksums.Pipe{}, // checksums of the files
|
||||
sign.Pipe{}, // sign artifacts
|
||||
docker.Pipe{}, // create and push docker images
|
||||
artifactory.Pipe{}, // push to artifactory
|
||||
publish.Pipe{}, // publishes artifacts
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user