Skip to content
Permalink
Browse files

chore: move defaulter to pkg, so godownloader can use it

  • Loading branch information...
caarlos0 committed Oct 26, 2018
1 parent 3010023 commit 6f312b993b8e91caaefe2413931fb04042e4aed2
Showing with 54 additions and 45 deletions.
  1. +2 −45 internal/pipe/defaults/defaults.go
  2. +52 −0 pkg/defaults/defaults.go
@@ -3,25 +3,9 @@
package defaults

import (
"fmt"

"github.com/apex/log"
"github.com/goreleaser/goreleaser/internal/pipe/archive"
"github.com/goreleaser/goreleaser/internal/pipe/artifactory"
"github.com/goreleaser/goreleaser/internal/pipe/brew"
"github.com/goreleaser/goreleaser/internal/pipe/build"
"github.com/goreleaser/goreleaser/internal/pipe/checksums"
"github.com/goreleaser/goreleaser/internal/pipe/docker"
"github.com/goreleaser/goreleaser/internal/pipe/env"
"github.com/goreleaser/goreleaser/internal/pipe/nfpm"
"github.com/goreleaser/goreleaser/internal/pipe/project"
"github.com/goreleaser/goreleaser/internal/pipe/release"
"github.com/goreleaser/goreleaser/internal/pipe/s3"
"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/snapshot"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/goreleaser/goreleaser/pkg/defaults"
)

// Pipe that sets the defaults
@@ -31,33 +15,6 @@ func (Pipe) String() string {
return "setting defaults"
}

// Defaulter can be implemented by a Piper to set default values for its
// configuration.
type Defaulter interface {
fmt.Stringer

// Default sets the configuration defaults
Default(ctx *context.Context) error
}

var defaulters = []Defaulter{
env.Pipe{},
snapshot.Pipe{},
release.Pipe{},
project.Pipe{},
archive.Pipe{},
build.Pipe{},
nfpm.Pipe{},
snapcraft.Pipe{},
checksums.Pipe{},
sign.Pipe{},
docker.Pipe{},
artifactory.Pipe{},
s3.Pipe{},
brew.Pipe{},
scoop.Pipe{},
}

// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
if ctx.Config.Dist == "" {
@@ -66,7 +23,7 @@ func (Pipe) Run(ctx *context.Context) error {
if ctx.Config.GitHubURLs.Download == "" {
ctx.Config.GitHubURLs.Download = "https://github.com"
}
for _, defaulter := range defaulters {
for _, defaulter := range defaults.Defaulters {
log.Debug(defaulter.String())
if err := defaulter.Default(ctx); err != nil {
return err
@@ -0,0 +1,52 @@
// Package defaults make the list of Defaulter implementations available
// so projects extending GoReleaser are able to use it, namely, GoDownloader.
package defaults

import (
"fmt"

"github.com/goreleaser/goreleaser/internal/pipe/archive"
"github.com/goreleaser/goreleaser/internal/pipe/artifactory"
"github.com/goreleaser/goreleaser/internal/pipe/brew"
"github.com/goreleaser/goreleaser/internal/pipe/build"
"github.com/goreleaser/goreleaser/internal/pipe/checksums"
"github.com/goreleaser/goreleaser/internal/pipe/docker"
"github.com/goreleaser/goreleaser/internal/pipe/env"
"github.com/goreleaser/goreleaser/internal/pipe/nfpm"
"github.com/goreleaser/goreleaser/internal/pipe/project"
"github.com/goreleaser/goreleaser/internal/pipe/release"
"github.com/goreleaser/goreleaser/internal/pipe/s3"
"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/snapshot"
"github.com/goreleaser/goreleaser/pkg/context"
)

// Defaulter can be implemented by a Piper to set default values for its
// configuration.
type Defaulter interface {
fmt.Stringer

// Default sets the configuration defaults
Default(ctx *context.Context) error
}

// Defaulters is the list of defaulters
var Defaulters = []Defaulter{
env.Pipe{},
snapshot.Pipe{},
release.Pipe{},
project.Pipe{},
archive.Pipe{},
build.Pipe{},
nfpm.Pipe{},
snapcraft.Pipe{},
checksums.Pipe{},
sign.Pipe{},
docker.Pipe{},
artifactory.Pipe{},
s3.Pipe{},
brew.Pipe{},
scoop.Pipe{},
}

0 comments on commit 6f312b9

Please sign in to comment.
You can’t perform that action at this time.