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