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 (
|
2019-01-22 05:56:16 +02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/middleware"
|
2018-08-15 04:50:20 +02:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
2018-10-26 16:03:55 +02:00
|
|
|
"github.com/goreleaser/goreleaser/pkg/defaults"
|
2017-01-14 16:34:22 +02:00
|
|
|
)
|
|
|
|
|
2020-05-26 05:48:10 +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 {
|
2018-10-05 14:48:00 +02:00
|
|
|
return "setting defaults"
|
2017-12-02 23:53:19 +02:00
|
|
|
}
|
|
|
|
|
2020-05-26 05:48:10 +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"
|
|
|
|
}
|
2018-03-08 22:16:49 +02: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 16:03:55 +02:00
|
|
|
for _, defaulter := range defaults.Defaulters {
|
2019-01-22 05:56:16 +02:00
|
|
|
if err := middleware.Logging(
|
|
|
|
defaulter.String(),
|
|
|
|
middleware.ErrHandler(defaulter.Default),
|
|
|
|
middleware.ExtraPadding,
|
|
|
|
)(ctx); err != nil {
|
2017-12-02 23:53:19 +02:00
|
|
|
return err
|
|
|
|
}
|
2017-05-01 14:59:18 +02:00
|
|
|
}
|
2017-01-14 20:41:32 +02:00
|
|
|
return nil
|
2017-01-14 16:34:22 +02:00
|
|
|
}
|