1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00

77 lines
2.1 KiB
Go
Raw Normal View History

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 (
"fmt"
2017-06-27 19:20:08 -03:00
"github.com/apex/log"
"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
)
// Pipe that sets the defaults
2017-01-14 12:34:22 -02:00
type Pipe struct{}
func (Pipe) String() string {
return "setting defaults for:"
}
// 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{},
snapshot.Pipe{},
release.Pipe{},
project.Pipe{},
archive.Pipe{},
build.Pipe{},
nfpm.Pipe{},
2017-12-26 21:45:53 -02:00
snapcraft.Pipe{},
checksums.Pipe{},
sign.Pipe{},
docker.Pipe{},
artifactory.Pipe{},
2018-05-13 13:08:14 -03:00
s3.Pipe{},
brew.Pipe{},
scoop.Pipe{},
2017-01-14 12:34:22 -02:00
}
// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
if ctx.Config.Dist == "" {
ctx.Config.Dist = "dist"
}
if ctx.Config.GitHubURLs.Download == "" {
ctx.Config.GitHubURLs.Download = "https://github.com"
}
for _, defaulter := range defaulters {
log.Info(defaulter.String())
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
}