2017-04-14 15:39:32 -03:00
|
|
|
// Package defaults implements the Pipe interface providing default values
|
|
|
|
// for missing configuration.
|
2017-01-14 12:34:22 -02:00
|
|
|
package defaults
|
|
|
|
|
|
|
|
import (
|
2018-03-08 18:36:36 -03:00
|
|
|
"fmt"
|
|
|
|
|
2017-06-27 19:20:08 -03:00
|
|
|
"github.com/apex/log"
|
2018-08-14 23:50:20 -03:00
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/archive"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/artifactory"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/brew"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/build"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/checksums"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/docker"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/env"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/nfpm"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/project"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/release"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/s3"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/scoop"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/sign"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/snapcraft"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/pipeline/snapshot"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
2017-01-14 12:34:22 -02:00
|
|
|
)
|
|
|
|
|
2017-12-10 11:28:01 -02:00
|
|
|
// Pipe that sets the defaults
|
2017-01-14 12:34:22 -02:00
|
|
|
type Pipe struct{}
|
|
|
|
|
2017-12-02 19:53:19 -02:00
|
|
|
func (Pipe) String() string {
|
|
|
|
return "setting defaults for:"
|
|
|
|
}
|
|
|
|
|
2018-03-08 18:36:36 -03:00
|
|
|
// 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{
|
2018-02-03 00:06:48 -02:00
|
|
|
env.Pipe{},
|
2017-12-02 19:53:19 -02:00
|
|
|
snapshot.Pipe{},
|
|
|
|
release.Pipe{},
|
2018-03-12 08:42:31 -03:00
|
|
|
project.Pipe{},
|
2017-12-02 19:53:19 -02:00
|
|
|
archive.Pipe{},
|
|
|
|
build.Pipe{},
|
2018-02-17 12:16:06 -02:00
|
|
|
nfpm.Pipe{},
|
2017-12-26 21:45:53 -02:00
|
|
|
snapcraft.Pipe{},
|
2017-12-02 19:53:19 -02:00
|
|
|
checksums.Pipe{},
|
2017-12-13 17:14:01 +01:00
|
|
|
sign.Pipe{},
|
2017-12-02 19:53:19 -02:00
|
|
|
docker.Pipe{},
|
2017-12-09 20:54:04 +01:00
|
|
|
artifactory.Pipe{},
|
2018-05-13 13:08:14 -03:00
|
|
|
s3.Pipe{},
|
2017-12-02 19:53:19 -02:00
|
|
|
brew.Pipe{},
|
2018-02-10 12:38:07 +00:00
|
|
|
scoop.Pipe{},
|
2017-01-14 12:34:22 -02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run the pipe
|
2017-12-02 19:53:19 -02:00
|
|
|
func (Pipe) Run(ctx *context.Context) error {
|
2017-11-26 21:25:51 -02:00
|
|
|
if ctx.Config.Dist == "" {
|
|
|
|
ctx.Config.Dist = "dist"
|
|
|
|
}
|
2018-03-08 17:16:49 -03:00
|
|
|
if ctx.Config.GitHubURLs.Download == "" {
|
|
|
|
ctx.Config.GitHubURLs.Download = "https://github.com"
|
|
|
|
}
|
2017-12-02 19:53:19 -02:00
|
|
|
for _, defaulter := range defaulters {
|
2017-12-06 01:02:52 -02:00
|
|
|
log.Info(defaulter.String())
|
2017-12-02 19:53:19 -02:00
|
|
|
if err := defaulter.Default(ctx); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-01 09:59:18 -03:00
|
|
|
}
|
2017-01-14 19:41:32 +01:00
|
|
|
return nil
|
2017-01-14 12:34:22 -02:00
|
|
|
}
|