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 (
|
2017-06-27 19:20:08 -03:00
|
|
|
"github.com/apex/log"
|
2017-01-14 20:01:32 -02:00
|
|
|
"github.com/goreleaser/goreleaser/context"
|
2017-12-02 19:53:19 -02:00
|
|
|
"github.com/goreleaser/goreleaser/pipeline"
|
|
|
|
"github.com/goreleaser/goreleaser/pipeline/archive"
|
2017-12-09 20:54:04 +01:00
|
|
|
"github.com/goreleaser/goreleaser/pipeline/artifactory"
|
2017-12-02 19: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 00:06:48 -02:00
|
|
|
"github.com/goreleaser/goreleaser/pipeline/env"
|
2017-12-02 19:53:19 -02:00
|
|
|
"github.com/goreleaser/goreleaser/pipeline/fpm"
|
|
|
|
"github.com/goreleaser/goreleaser/pipeline/release"
|
2018-02-10 12:38:07 +00:00
|
|
|
"github.com/goreleaser/goreleaser/pipeline/scoop"
|
2017-12-13 17:14:01 +01:00
|
|
|
"github.com/goreleaser/goreleaser/pipeline/sign"
|
2017-12-26 21:45:53 -02:00
|
|
|
"github.com/goreleaser/goreleaser/pipeline/snapcraft"
|
2017-12-02 19:53:19 -02:00
|
|
|
"github.com/goreleaser/goreleaser/pipeline/snapshot"
|
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:"
|
|
|
|
}
|
|
|
|
|
|
|
|
var defaulters = []pipeline.Defaulter{
|
2018-02-03 00:06:48 -02:00
|
|
|
env.Pipe{},
|
2017-12-02 19:53:19 -02:00
|
|
|
snapshot.Pipe{},
|
|
|
|
release.Pipe{},
|
|
|
|
archive.Pipe{},
|
|
|
|
build.Pipe{},
|
|
|
|
fpm.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{},
|
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"
|
|
|
|
}
|
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-07-01 22:42:10 -03:00
|
|
|
if ctx.Config.ProjectName == "" {
|
|
|
|
ctx.Config.ProjectName = ctx.Config.Release.GitHub.Name
|
2017-06-27 19:20:08 -03:00
|
|
|
}
|
2017-01-14 19:41:32 +01:00
|
|
|
return nil
|
2017-01-14 12:34:22 -02:00
|
|
|
}
|