Skip to content

Commit

Permalink
refactor: docker sign is actually a publisher
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Sep 11, 2021
1 parent 435593a commit 7b0b88f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 2 additions & 0 deletions internal/pipe/publish/publish.go
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/goreleaser/goreleaser/internal/pipe/milestone"
"github.com/goreleaser/goreleaser/internal/pipe/release"
"github.com/goreleaser/goreleaser/internal/pipe/scoop"
"github.com/goreleaser/goreleaser/internal/pipe/sign"
"github.com/goreleaser/goreleaser/internal/pipe/snapcraft"
"github.com/goreleaser/goreleaser/internal/pipe/upload"
"github.com/goreleaser/goreleaser/pkg/context"
Expand Down Expand Up @@ -41,6 +42,7 @@ var publishers = []Publisher{
artifactory.Pipe{},
docker.Pipe{},
docker.ManifestPipe{},
sign.DockerPipe{},
snapcraft.Pipe{},
// This should be one of the last steps
release.Pipe{},
Expand Down
4 changes: 2 additions & 2 deletions internal/pipe/sign/sign_docker.go
Expand Up @@ -39,8 +39,8 @@ func (DockerPipe) Default(ctx *context.Context) error {
return ids.Validate()
}

// Run executes the Pipe.
func (DockerPipe) Run(ctx *context.Context) error {
// Publish signs and pushes the docker images signatures.
func (DockerPipe) Publish(ctx *context.Context) error {
if ctx.SkipSign {
return pipe.ErrSkipSignEnabled
}
Expand Down
10 changes: 5 additions & 5 deletions internal/pipe/sign/sign_docker_test.go
Expand Up @@ -33,21 +33,21 @@ func TestDockerSignDisabled(t *testing.T) {
ctx.Config.DockerSigns = []config.Sign{
{Artifacts: "none"},
}
err := DockerPipe{}.Run(ctx)
err := DockerPipe{}.Publish(ctx)
require.EqualError(t, err, "artifact signing is disabled")
}

func TestDockerSignSkipped(t *testing.T) {
ctx := context.New(config.Project{})
ctx.SkipSign = true
err := DockerPipe{}.Run(ctx)
err := DockerPipe{}.Publish(ctx)
require.EqualError(t, err, "artifact signing is disabled")
}

func TestDockerSignSkipPublish(t *testing.T) {
ctx := context.New(config.Project{})
ctx.SkipPublish = true
err := DockerPipe{}.Run(ctx)
err := DockerPipe{}.Publish(ctx)
require.EqualError(t, err, "artifact signing is disabled")
}

Expand All @@ -56,7 +56,7 @@ func TestDockerSignInvalidArtifacts(t *testing.T) {
ctx.Config.DockerSigns = []config.Sign{
{Artifacts: "foo"},
}
err := DockerPipe{}.Run(ctx)
err := DockerPipe{}.Publish(ctx)
require.EqualError(t, err, "invalid list of artifacts to sign: foo")
}

Expand Down Expand Up @@ -178,7 +178,7 @@ func TestDockerSignArtifacts(t *testing.T) {
})

require.NoError(t, DockerPipe{}.Default(ctx))
require.NoError(t, DockerPipe{}.Run(ctx))
require.NoError(t, DockerPipe{}.Publish(ctx))
var sigs []string
for _, sig := range ctx.Artifacts.Filter(artifact.ByType(artifact.Signature)).List() {
sigs = append(sigs, sig.Name)
Expand Down
8 changes: 3 additions & 5 deletions internal/pipeline/pipeline.go
Expand Up @@ -5,10 +5,6 @@ import (
"fmt"

"github.com/goreleaser/goreleaser/internal/pipe/announce"
"github.com/goreleaser/goreleaser/internal/pipe/gomod"
"github.com/goreleaser/goreleaser/internal/pipe/semver"
"github.com/goreleaser/goreleaser/internal/pipe/sourcearchive"

"github.com/goreleaser/goreleaser/internal/pipe/archive"
"github.com/goreleaser/goreleaser/internal/pipe/before"
"github.com/goreleaser/goreleaser/internal/pipe/build"
Expand All @@ -20,11 +16,14 @@ import (
"github.com/goreleaser/goreleaser/internal/pipe/effectiveconfig"
"github.com/goreleaser/goreleaser/internal/pipe/env"
"github.com/goreleaser/goreleaser/internal/pipe/git"
"github.com/goreleaser/goreleaser/internal/pipe/gomod"
"github.com/goreleaser/goreleaser/internal/pipe/nfpm"
"github.com/goreleaser/goreleaser/internal/pipe/publish"
"github.com/goreleaser/goreleaser/internal/pipe/semver"
"github.com/goreleaser/goreleaser/internal/pipe/sign"
"github.com/goreleaser/goreleaser/internal/pipe/snapcraft"
"github.com/goreleaser/goreleaser/internal/pipe/snapshot"
"github.com/goreleaser/goreleaser/internal/pipe/sourcearchive"
"github.com/goreleaser/goreleaser/pkg/context"
)

Expand Down Expand Up @@ -64,6 +63,5 @@ var Pipeline = append(
sign.Pipe{}, // sign artifacts
docker.Pipe{}, // create and push docker images
publish.Pipe{}, // publishes artifacts
sign.DockerPipe{}, // sign docker images and manifests
announce.Pipe{}, // announce releases
)

1 comment on commit 7b0b88f

@vercel
Copy link

@vercel vercel bot commented on 7b0b88f Sep 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.