mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix: improved deprecation warning output
This commit is contained in:
parent
dd3b0cdcf2
commit
d13a97b46d
@ -11,6 +11,7 @@ import (
|
||||
"text/template"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/apex/log/handlers/cli"
|
||||
"github.com/fatih/color"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@ -31,13 +32,20 @@ func (Pipe) String() string {
|
||||
return "creating Docker images"
|
||||
}
|
||||
|
||||
func deprecateWarn(format string, a ...interface{}) {
|
||||
cli.Default.Padding *= 2
|
||||
defer func() {
|
||||
cli.Default.Padding /= 2
|
||||
}()
|
||||
log.Warn(color.New(color.Bold, color.FgHiYellow).Sprintf(format, a...))
|
||||
}
|
||||
|
||||
// Default sets the pipe defaults
|
||||
func (Pipe) Default(ctx *context.Context) error {
|
||||
var deprecate = color.New(color.Bold, color.FgHiYellow)
|
||||
for i := range ctx.Config.Dockers {
|
||||
var docker = &ctx.Config.Dockers[i]
|
||||
if docker.OldTagTemplate != "" {
|
||||
log.Warn(deprecate.Sprintf("`dockers[%d].tag_template` is deprecated. Please consider using `dockers[%d].tag_templates` instead", i, i))
|
||||
deprecateWarn("`dockers[%d].tag_template` is deprecated. Please consider using `dockers[%d].tag_templates` instead", i, i)
|
||||
docker.TagTemplates = append(docker.TagTemplates, docker.OldTagTemplate)
|
||||
}
|
||||
if len(docker.TagTemplates) == 0 {
|
||||
@ -50,7 +58,7 @@ func (Pipe) Default(ctx *context.Context) error {
|
||||
docker.Goarch = "amd64"
|
||||
}
|
||||
if docker.Latest {
|
||||
log.Warn(deprecate.Sprintf("`dockers[%d].latest` is deprecated. Please consider adding a `latest` tag to the `dockers[%d].tag_templates` list instead", i, i))
|
||||
deprecateWarn("`dockers[%d].latest` is deprecated. Please consider adding a `latest` tag to the `dockers[%d].tag_templates` list instead", i, i)
|
||||
docker.TagTemplates = append(docker.TagTemplates, "latest")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user