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 (
|
2019-01-22 01:56:16 -02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/middleware"
|
2018-08-14 23:50:20 -03:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
2018-10-26 11:03:55 -03:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/defaults"
|
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 {
|
2018-10-05 09:48:00 -03:00
|
|
|
return "setting defaults"
|
2017-12-02 19:53:19 -02:00
|
|
|
}
|
|
|
|
|
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"
|
|
|
|
}
|
2019-06-29 16:02:40 +02:00
|
|
|
if ctx.Config.GitLabURLs.Download == "" {
|
|
|
|
ctx.Config.GitLabURLs.Download = "https://gitlab.com"
|
|
|
|
}
|
2018-10-26 11:03:55 -03:00
|
|
|
for _, defaulter := range defaults.Defaulters {
|
2019-01-22 01:56:16 -02:00
|
|
|
if err := middleware.Logging(
|
|
|
|
defaulter.String(),
|
|
|
|
middleware.ErrHandler(defaulter.Default),
|
|
|
|
middleware.ExtraPadding,
|
|
|
|
)(ctx); err != nil {
|
2017-12-02 19:53:19 -02:00
|
|
|
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
|
|
|
}
|