mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-19 20:57:53 +02:00
clean: removed deprecated docker options (#759)
* clean: remove fpm completely * clean: remove docker tag_template and latest
This commit is contained in:
parent
f0b7608f4d
commit
a04724d6b8
@ -12,7 +12,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||
"github.com/goreleaser/goreleaser/internal/deprecate"
|
||||
"github.com/goreleaser/goreleaser/internal/pipeline"
|
||||
"github.com/goreleaser/goreleaser/internal/semerrgroup"
|
||||
"github.com/goreleaser/goreleaser/internal/tmpl"
|
||||
@ -34,10 +33,6 @@ func (Pipe) String() string {
|
||||
func (Pipe) Default(ctx *context.Context) error {
|
||||
for i := range ctx.Config.Dockers {
|
||||
var docker = &ctx.Config.Dockers[i]
|
||||
if docker.OldTagTemplate != "" {
|
||||
deprecate.Notice("docker.tag_template")
|
||||
docker.TagTemplates = append(docker.TagTemplates, docker.OldTagTemplate)
|
||||
}
|
||||
if len(docker.TagTemplates) == 0 {
|
||||
docker.TagTemplates = append(docker.TagTemplates, "{{ .Version }}")
|
||||
}
|
||||
@ -47,10 +42,6 @@ func (Pipe) Default(ctx *context.Context) error {
|
||||
if docker.Goarch == "" {
|
||||
docker.Goarch = "amd64"
|
||||
}
|
||||
if docker.Latest {
|
||||
deprecate.Notice("docker.latest")
|
||||
docker.TagTemplates = append(docker.TagTemplates, "latest")
|
||||
}
|
||||
}
|
||||
// only set defaults if there is exacly 1 docker setup in the config file.
|
||||
if len(ctx.Config.Dockers) != 1 {
|
||||
@ -188,7 +179,7 @@ func dockerBuild(ctx *context.Context, root, dockerfile, image string) error {
|
||||
log.WithField("image", image).Info("building docker image")
|
||||
/* #nosec */
|
||||
var cmd = exec.CommandContext(ctx, "docker", "build", "-f", dockerfile, "-t", image, root)
|
||||
log.WithField("cmd", cmd.Args).Debug("running")
|
||||
log.WithField("cmd", cmd.Args).Info("running")
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to build docker image: \n%s", string(out))
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"github.com/goreleaser/goreleaser/pkg/config"
|
||||
"github.com/goreleaser/goreleaser/pkg/context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var it = flag.Bool("it", false, "push images to docker hub")
|
||||
@ -52,12 +53,12 @@ func TestRunPipe(t *testing.T) {
|
||||
type errChecker func(*testing.T, error)
|
||||
var shouldErr = func(msg string) errChecker {
|
||||
return func(t *testing.T, err error) {
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), msg)
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), msg)
|
||||
}
|
||||
}
|
||||
var shouldNotErr = func(t *testing.T, err error) {
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
var table = map[string]struct {
|
||||
@ -202,7 +203,7 @@ func TestRunPipe(t *testing.T) {
|
||||
publish: true,
|
||||
dockers: []config.Docker{
|
||||
{
|
||||
Image: registry + "goreleaser/test_run_pipe",
|
||||
Image: registry + "goreleaser/bad_dockerfile",
|
||||
Goos: "linux",
|
||||
Goarch: "amd64",
|
||||
Dockerfile: "testdata/Dockerfile.bad",
|
||||
@ -259,7 +260,6 @@ func TestRunPipe(t *testing.T) {
|
||||
"{{.Tag}}",
|
||||
"latest",
|
||||
},
|
||||
Latest: true,
|
||||
},
|
||||
},
|
||||
expect: []string{
|
||||
@ -325,13 +325,13 @@ func TestRunPipe(t *testing.T) {
|
||||
for name, docker := range table {
|
||||
t.Run(name, func(tt *testing.T) {
|
||||
folder, err := ioutil.TempDir("", "archivetest")
|
||||
assert.NoError(tt, err)
|
||||
require.NoError(tt, err)
|
||||
var dist = filepath.Join(folder, "dist")
|
||||
assert.NoError(tt, os.Mkdir(dist, 0755))
|
||||
assert.NoError(tt, os.Mkdir(filepath.Join(dist, "mybin"), 0755))
|
||||
require.NoError(tt, os.Mkdir(dist, 0755))
|
||||
require.NoError(tt, os.Mkdir(filepath.Join(dist, "mybin"), 0755))
|
||||
var binPath = filepath.Join(dist, "mybin", "mybin")
|
||||
_, err = os.Create(binPath)
|
||||
assert.NoError(tt, err)
|
||||
require.NoError(tt, err)
|
||||
|
||||
var ctx = context.New(config.Project{
|
||||
ProjectName: "mybin",
|
||||
@ -366,13 +366,13 @@ func TestRunPipe(t *testing.T) {
|
||||
_ = exec.Command("docker", "rmi", img).Run()
|
||||
}
|
||||
|
||||
docker.assertError(t, Pipe{}.Run(ctx))
|
||||
docker.assertError(tt, Pipe{}.Run(ctx))
|
||||
|
||||
// this might should not fail as the image should have been created when
|
||||
// the step ran
|
||||
for _, img := range docker.expect {
|
||||
tt.Log("removing docker image", img)
|
||||
assert.NoError(tt, exec.Command("docker", "rmi", img).Run(), "could not delete image %s", img)
|
||||
require.NoError(tt, exec.Command("docker", "rmi", img).Run(), "could not delete image %s", img)
|
||||
}
|
||||
|
||||
})
|
||||
@ -425,9 +425,7 @@ func TestDefault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Dockers: []config.Docker{
|
||||
{
|
||||
Latest: true,
|
||||
},
|
||||
{},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -438,8 +436,7 @@ func TestDefault(t *testing.T) {
|
||||
assert.Equal(t, "amd64", docker.Goarch)
|
||||
assert.Equal(t, ctx.Config.Builds[0].Binary, docker.Binary)
|
||||
assert.Equal(t, "Dockerfile", docker.Dockerfile)
|
||||
assert.Empty(t, docker.OldTagTemplate)
|
||||
assert.Equal(t, []string{"{{ .Version }}", "latest"}, docker.TagTemplates)
|
||||
assert.Equal(t, []string{"{{ .Version }}"}, docker.TagTemplates)
|
||||
|
||||
}
|
||||
|
||||
@ -472,31 +469,9 @@ func TestDefaultSet(t *testing.T) {
|
||||
assert.Equal(t, "windows", docker.Goos)
|
||||
assert.Equal(t, "i386", docker.Goarch)
|
||||
assert.Equal(t, "bar", docker.Binary)
|
||||
assert.Empty(t, docker.OldTagTemplate)
|
||||
assert.Equal(t, []string{"{{ .Version }}"}, docker.TagTemplates)
|
||||
assert.Equal(t, "Dockerfile.foo", docker.Dockerfile)
|
||||
}
|
||||
|
||||
func TestDefaultWithOldTagTemplateSet(t *testing.T) {
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
Dockers: []config.Docker{
|
||||
{
|
||||
Dockerfile: "Dockerfile.foo",
|
||||
OldTagTemplate: "{{.Tag}}",
|
||||
Latest: true,
|
||||
Binary: "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
assert.NoError(t, Pipe{}.Default(ctx))
|
||||
assert.Len(t, ctx.Config.Dockers, 1)
|
||||
var docker = ctx.Config.Dockers[0]
|
||||
assert.Equal(t, []string{"{{.Tag}}", "latest"}, docker.TagTemplates)
|
||||
assert.Equal(t, "Dockerfile.foo", docker.Dockerfile)
|
||||
}
|
||||
|
||||
func TestLinkFile(t *testing.T) {
|
||||
const srcFile = "/tmp/test"
|
||||
const dstFile = "/tmp/linked"
|
||||
|
@ -235,17 +235,15 @@ type Checksum struct {
|
||||
|
||||
// Docker image config
|
||||
type Docker struct {
|
||||
Binary string `yaml:",omitempty"`
|
||||
Goos string `yaml:",omitempty"`
|
||||
Goarch string `yaml:",omitempty"`
|
||||
Goarm string `yaml:",omitempty"`
|
||||
Image string `yaml:",omitempty"`
|
||||
Dockerfile string `yaml:",omitempty"`
|
||||
Latest bool `yaml:",omitempty"`
|
||||
SkipPush bool `yaml:"skip_push,omitempty"`
|
||||
OldTagTemplate string `yaml:"tag_template,omitempty"`
|
||||
TagTemplates []string `yaml:"tag_templates,omitempty"`
|
||||
Files []string `yaml:"extra_files,omitempty"`
|
||||
Binary string `yaml:",omitempty"`
|
||||
Goos string `yaml:",omitempty"`
|
||||
Goarch string `yaml:",omitempty"`
|
||||
Goarm string `yaml:",omitempty"`
|
||||
Image string `yaml:",omitempty"`
|
||||
Dockerfile string `yaml:",omitempty"`
|
||||
SkipPush bool `yaml:"skip_push,omitempty"`
|
||||
TagTemplates []string `yaml:"tag_templates,omitempty"`
|
||||
Files []string `yaml:"extra_files,omitempty"`
|
||||
}
|
||||
|
||||
// Filters config
|
||||
|
@ -62,11 +62,12 @@ nfpm:
|
||||
# ...
|
||||
```
|
||||
|
||||
## docker.name_template
|
||||
## docker.tag_template
|
||||
|
||||
> since 2018-01-19
|
||||
> removed 2017-08-15
|
||||
|
||||
This property was deprecated in favor of the pluralized `name_templates`.
|
||||
This property was deprecated in favor of the pluralized `tag_templates`.
|
||||
The idea is to be able to define several tags instead of just one.
|
||||
|
||||
Change this:
|
||||
@ -74,7 +75,7 @@ Change this:
|
||||
```yaml
|
||||
dockers:
|
||||
- image: foo/bar
|
||||
name_template: '{{ .Tag }}'
|
||||
tag_template: '{{ .Tag }}'
|
||||
```
|
||||
|
||||
to this:
|
||||
@ -89,6 +90,7 @@ dockers:
|
||||
## docker.latest
|
||||
|
||||
> since 2018-01-19
|
||||
> removed 2017-08-15
|
||||
|
||||
The `latest` field in Docker config is deprecated in favor of the newer
|
||||
`tag_templates` field.
|
||||
|
Loading…
x
Reference in New Issue
Block a user