From 5901845529a35570415d960537e4cf710e746b0c Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 10 Jan 2019 23:06:24 -0200 Subject: [PATCH 1/7] feat: support multiple binaries on docker --- internal/pipe/docker/docker.go | 40 +++++++++++++------ internal/pipe/docker/docker_test.go | 21 +++++++++- pkg/config/config.go | 1 + www/content/deprecations.md | 62 +++++++++++++++++++---------- www/content/docker.md | 19 +++++---- 5 files changed, 101 insertions(+), 42 deletions(-) diff --git a/internal/pipe/docker/docker.go b/internal/pipe/docker/docker.go index 2d10a922201..776b36bfa0f 100644 --- a/internal/pipe/docker/docker.go +++ b/internal/pipe/docker/docker.go @@ -45,6 +45,11 @@ func (Pipe) Default(ctx *context.Context) error { } } + if docker.Binary != "" { + deprecate.Notice("docker.binary") + docker.Binaries = append(docker.Binaries, docker.Binary) + } + if docker.Goos == "" { docker.Goos = "linux" } @@ -56,8 +61,10 @@ func (Pipe) Default(ctx *context.Context) error { if len(ctx.Config.Dockers) != 1 { return nil } - if ctx.Config.Dockers[0].Binary == "" { - ctx.Config.Dockers[0].Binary = ctx.Config.Builds[0].Binary + if len(ctx.Config.Dockers[0].Binaries) == 0 { + ctx.Config.Dockers[0].Binaries = []string{ + ctx.Config.Builds[0].Binary, + } } if ctx.Config.Dockers[0].Dockerfile == "" { ctx.Config.Dockers[0].Dockerfile = "Dockerfile" @@ -105,31 +112,36 @@ func doRun(ctx *context.Context) error { artifact.ByGoarm(docker.Goarm), artifact.ByType(artifact.Binary), func(a artifact.Artifact) bool { - return a.ExtraOr("Binary", "").(string) == docker.Binary + for _, bin := range docker.Binaries { + if a.ExtraOr("Binary", "").(string) == bin { + return true + } + } + return false }, ), ).List() - if len(binaries) != 1 { + if len(binaries) == 0 { return fmt.Errorf( - "%d binaries match docker definition: %s: %s_%s_%s", - len(binaries), - docker.Binary, docker.Goos, docker.Goarch, docker.Goarm, + "no binaries match docker definition: %s_%s_%s and binaries %v", + docker.Goos, docker.Goarch, docker.Goarm, docker.Binaries, ) } - return process(ctx, docker, binaries[0]) + return process(ctx, docker, binaries) }) } return g.Wait() } -func process(ctx *context.Context, docker config.Docker, bin artifact.Artifact) error { +func process(ctx *context.Context, docker config.Docker, bins []artifact.Artifact) error { tmp, err := ioutil.TempDir(ctx.Config.Dist, "goreleaserdocker") if err != nil { return errors.Wrap(err, "failed to create temporary dir") } log.Debug("tempdir: " + tmp) - images, err := processImageTemplates(ctx, docker, bin) + // TODO: templates using Binary will only work with the first binary + images, err := processImageTemplates(ctx, docker, bins[0]) if err != nil { return err } @@ -145,11 +157,13 @@ func process(ctx *context.Context, docker config.Docker, bin artifact.Artifact) return errors.Wrapf(err, "failed to link extra file '%s'", file) } } - if err := os.Link(bin.Path, filepath.Join(tmp, filepath.Base(bin.Path))); err != nil { - return errors.Wrap(err, "failed to link binary") + for _, bin := range bins { + if err := os.Link(bin.Path, filepath.Join(tmp, filepath.Base(bin.Path))); err != nil { + return errors.Wrap(err, "failed to link binary") + } } - buildFlags, err := processBuildFlagTemplates(ctx, docker, bin) + buildFlags, err := processBuildFlagTemplates(ctx, docker, bins[0]) if err != nil { return err } diff --git a/internal/pipe/docker/docker_test.go b/internal/pipe/docker/docker_test.go index a6c2c4255d1..216dfd514c3 100644 --- a/internal/pipe/docker/docker_test.go +++ b/internal/pipe/docker/docker_test.go @@ -691,8 +691,25 @@ func TestDefault(t *testing.T) { var docker = ctx.Config.Dockers[0] assert.Equal(t, "linux", docker.Goos) assert.Equal(t, "amd64", docker.Goarch) - assert.Equal(t, ctx.Config.Builds[0].Binary, docker.Binary) - assert.Equal(t, "Dockerfile", docker.Dockerfile) + assert.Equal(t, []string{ctx.Config.Builds[0].Binary}, docker.Binaries) +} + +func TestDefaultBinaries(t *testing.T) { + var ctx = &context.Context{ + Config: config.Project{ + Dockers: []config.Docker{ + { + Binary: "foo", + }, + }, + }, + } + assert.NoError(t, Pipe{}.Default(ctx)) + assert.Len(t, ctx.Config.Dockers, 1) + var docker = ctx.Config.Dockers[0] + assert.Equal(t, "linux", docker.Goos) + assert.Equal(t, "amd64", docker.Goarch) + assert.Equal(t, []string{"foo"}, docker.Binaries) } func TestDefaultNoDockers(t *testing.T) { diff --git a/pkg/config/config.go b/pkg/config/config.go index 2b011d6784d..a5a250e8224 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -242,6 +242,7 @@ type Checksum struct { // Docker image config type Docker struct { Binary string `yaml:",omitempty"` + Binaries []string `yaml:",omitempty"` Goos string `yaml:",omitempty"` Goarch string `yaml:",omitempty"` Goarm string `yaml:",omitempty"` diff --git a/www/content/deprecations.md b/www/content/deprecations.md index 2b28d586e70..9227f788ef2 100644 --- a/www/content/deprecations.md +++ b/www/content/deprecations.md @@ -11,37 +11,58 @@ Deprecate code will be removed after ~6 months from the time it was deprecated. # Active deprecation notices -## docker.image + + +## docker.binary + +> since 2018-10-01 + +You can now create a Docker image with multiple binaries. Change this: ```yaml dockers: - image: foo/bar - tag_templates: - - '{{ .Tag }}' + binary: foo ``` to this: ```yaml dockers: -- image_templates: - - 'foo/bar:{{ .Tag }}' +- image: foo/bar + binaries: + - foo ``` -## docker.tag_templates +## docker.image > since 2018-10-20 This property was deprecated in favor of more flexible `image_templates`. The idea is to be able to define several images and tags using templates instead of just one image with tag templates. +This flexibility allows images to be pushed to multiple registries. Change this: @@ -60,29 +81,30 @@ dockers: - 'foo/bar:{{ .Tag }}' ``` +## docker.tag_templates - - ## git.short_hash > since 2018-10-03 diff --git a/www/content/docker.md b/www/content/docker.md index 5c5c9313875..6596f05f0a8 100644 --- a/www/content/docker.md +++ b/www/content/docker.md @@ -54,8 +54,9 @@ dockers: goarch: amd64 # GOARM of the built binary that should be used. goarm: '' - # Name of the built binary that should be used. - binary: mybinary + # Name of the built binaries that should be used. + binaries: + - mybinary # Templates of the Docker image names. image_templates: - "myuser/myimage:latest" @@ -103,7 +104,8 @@ That can be accomplished simply by adding template language in the definition: project: foo dockers: - - binary: mybinary + binaries: + - mybinary image_templates: - "myuser/{{.ProjectName}}" ``` @@ -124,7 +126,8 @@ accomplished by using multiple `image_templates`: # .goreleaser.yml dockers: - - binary: mybinary + binaries: + - mybinary image_templates: - "myuser/myimage:{{ .Tag }}" - "myuser/myimage:v{{ .Major }}" @@ -153,7 +156,8 @@ accomplished by using multiple `image_templates`: # .goreleaser.yml dockers: - - binary: mybinary + binaries: + - mybinary image_templates: - "docker.io/myuser/myimage:{{ .Tag }}" - "docker.io/myuser/myimage:latest" @@ -175,9 +179,10 @@ valid docker build flags. # .goreleaser.yml dockers: - - binary: mybinary + binaries: + - mybinary image_templates: - - "myuser/myimage" + - "myuser/myimage" build_flag_templates: - "--label=org.label-schema.schema-version=1.0" - "--label=org.label-schema.version={{.Version}}" From a4ba983911f3c14e15ae049401eb3486cd353865 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 10 Jan 2019 23:29:24 -0200 Subject: [PATCH 2/7] test: docker: fixed to use binaries --- internal/pipe/docker/docker_test.go | 52 ++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/internal/pipe/docker/docker_test.go b/internal/pipe/docker/docker_test.go index 216dfd514c3..0bd78749915 100644 --- a/internal/pipe/docker/docker_test.go +++ b/internal/pipe/docker/docker_test.go @@ -116,7 +116,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, BuildFlagTemplates: []string{ "--label=org.label-schema.schema-version=1.0", "--label=org.label-schema.version={{.Version}}", @@ -160,7 +160,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{ "{{.Tag}}-{{.Env.FOO}}", }, @@ -187,7 +187,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"latest"}, Files: []string{"testdata/extra_file.txt"}, }, @@ -196,7 +196,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"latest"}, Files: []string{"testdata/extra_file.txt"}, }, @@ -217,7 +217,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"latest"}, }, { @@ -225,7 +225,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"latest"}, }, }, @@ -245,7 +245,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, SkipPush: true, TagTemplates: []string{"latest"}, }, @@ -265,7 +265,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"{{.Version}}"}, }, }, @@ -284,7 +284,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"latest"}, }, }, @@ -303,7 +303,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"latest"}, BuildFlagTemplates: []string{ "--label=foo=bar", @@ -325,7 +325,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"latest"}, BuildFlagTemplates: []string{ "--bad-flag", @@ -343,7 +343,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile.bad", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"latest"}, }, }, @@ -358,7 +358,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{ "{{.Tag}", }, @@ -375,7 +375,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"latest"}, BuildFlagTemplates: []string{ "--label=tag={{.Tag}", @@ -393,7 +393,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{ "{{.Env.NOPE}}", }, @@ -410,7 +410,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, TagTemplates: []string{"latest"}, BuildFlagTemplates: []string{ "--label=nope={{.Env.NOPE}}", @@ -428,7 +428,7 @@ func TestRunPipe(t *testing.T) { Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", - Binary: "mybin", + Binaries: []string{"mybin"}, SkipPush: true, TagTemplates: []string{ "{{.Tag}}-{{.Env.FOO}}", @@ -451,7 +451,7 @@ func TestRunPipe(t *testing.T) { Image: "docker.io/nope", Goos: "linux", Goarch: "amd64", - Binary: "mybin", + Binaries: []string{"mybin"}, Dockerfile: "testdata/Dockerfile", TagTemplates: []string{"latest"}, }, @@ -470,7 +470,7 @@ func TestRunPipe(t *testing.T) { Image: "whatever", Goos: "linux", Goarch: "amd64", - Binary: "mybin", + Binaries: []string{"mybin"}, Dockerfile: "testdata/Dockerfilezzz", TagTemplates: []string{"latest"}, }, @@ -485,7 +485,7 @@ func TestRunPipe(t *testing.T) { Image: "whatever", Goos: "linux", Goarch: "amd64", - Binary: "mybin", + Binaries: []string{"mybin"}, Dockerfile: "testdata/Dockerfile", TagTemplates: []string{"latest"}, Files: []string{ @@ -503,7 +503,7 @@ func TestRunPipe(t *testing.T) { Image: "whatever", Goos: "darwin", Goarch: "amd64", - Binary: "mybinnnn", + Binaries: []string{"mybinnnn"}, Dockerfile: "testdata/Dockerfile", }, }, @@ -520,7 +520,7 @@ func TestRunPipe(t *testing.T) { Image: registry + "goreleaser/test_run_pipe", Goos: "darwin", Goarch: "amd64", - Binary: "mybin", + Binaries: []string{"mybin"}, Dockerfile: "testdata/Dockerfile", TagTemplates: []string{"latest"}, }, @@ -699,7 +699,7 @@ func TestDefaultBinaries(t *testing.T) { Config: config.Project{ Dockers: []config.Docker{ { - Binary: "foo", + Binaries: []string{"foo"}, }, }, }, @@ -729,7 +729,7 @@ func TestDefaultSet(t *testing.T) { { Goos: "windows", Goarch: "i386", - Binary: "bar", + Binaries: []string{"bar"}, Dockerfile: "Dockerfile.foo", }, }, @@ -751,7 +751,7 @@ func TestDefaultWithImage(t *testing.T) { { Goos: "windows", Goarch: "i386", - Binary: "bar", + Binaries: []string{"bar"}, Dockerfile: "Dockerfile.foo", Image: "my/image", }, @@ -794,7 +794,7 @@ func Test_processImageTemplates(t *testing.T) { Config: config.Project{ Dockers: []config.Docker{ { - Binary: "foo", + Binaries: []string{"foo"}, Image: tt.image, Dockerfile: "Dockerfile.foo", ImageTemplates: tt.imageTemplates, From df253a9f8545de4439be31e25470b470127a161b Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 11 Jan 2019 00:22:56 -0200 Subject: [PATCH 3/7] refactor: several docker pipe improvements --- internal/pipe/docker/docker.go | 51 ++- internal/pipe/docker/docker_test.go | 385 ++++++++---------- internal/pipe/docker/testdata/Dockerfile.bad | 1 - .../pipe/docker/testdata/Dockerfile.multiple | 3 + 4 files changed, 202 insertions(+), 238 deletions(-) create mode 100644 internal/pipe/docker/testdata/Dockerfile.multiple diff --git a/internal/pipe/docker/docker.go b/internal/pipe/docker/docker.go index 776b36bfa0f..de505ec5140 100644 --- a/internal/pipe/docker/docker.go +++ b/internal/pipe/docker/docker.go @@ -37,12 +37,18 @@ func (Pipe) Default(ctx *context.Context) error { if docker.Image != "" { deprecate.Notice("docker.image") + deprecate.Notice("docker.tag_templates") - if len(docker.TagTemplates) != 0 { - deprecate.Notice("docker.tag_templates") - } else { + if len(docker.TagTemplates) == 0 { docker.TagTemplates = []string{"{{ .Version }}"} } + + for _, tag := range docker.TagTemplates { + docker.ImageTemplates = append( + docker.ImageTemplates, + fmt.Sprintf("%s:%s", docker.Image, tag), + ) + } } if docker.Binary != "" { @@ -121,10 +127,14 @@ func doRun(ctx *context.Context) error { }, ), ).List() - if len(binaries) == 0 { + // TODO: not so good of a check, if one binary match multiple + // binaries and the other match none, this will still pass... + if len(binaries) != len(docker.Binaries) { return fmt.Errorf( - "no binaries match docker definition: %s_%s_%s and binaries %v", - docker.Goos, docker.Goarch, docker.Goarm, docker.Binaries, + "%d binaries match docker definition: %v: %s_%s_%s, should be %d", + len(binaries), + docker.Binaries, docker.Goos, docker.Goarch, docker.Goarm, + len(docker.Binaries), ) } return process(ctx, docker, binaries) @@ -140,8 +150,7 @@ func process(ctx *context.Context, docker config.Docker, bins []artifact.Artifac } log.Debug("tempdir: " + tmp) - // TODO: templates using Binary will only work with the first binary - images, err := processImageTemplates(ctx, docker, bins[0]) + images, err := processImageTemplates(ctx, docker, bins) if err != nil { return err } @@ -189,18 +198,16 @@ func process(ctx *context.Context, docker config.Docker, bins []artifact.Artifac return nil } -func processImageTemplates(ctx *context.Context, docker config.Docker, artifact artifact.Artifact) ([]string, error) { - if len(docker.ImageTemplates) != 0 && docker.Image != "" { - return nil, errors.New("failed to process image, use either image_templates (preferred) or image, not both") - } - +func processImageTemplates(ctx *context.Context, docker config.Docker, artifacts []artifact.Artifact) ([]string, error) { // nolint:prealloc var images []string for _, imageTemplate := range docker.ImageTemplates { // TODO: add overrides support to config - image, err := tmpl.New(ctx). - WithArtifact(artifact, map[string]string{}). - Apply(imageTemplate) + var t = tmpl.New(ctx) + if len(artifacts) == 1 { + t = t.WithArtifact(artifacts[0], map[string]string{}) + } + image, err := t.Apply(imageTemplate) if err != nil { return nil, errors.Wrapf(err, "failed to execute image template '%s'", imageTemplate) } @@ -208,18 +215,6 @@ func processImageTemplates(ctx *context.Context, docker config.Docker, artifact images = append(images, image) } - for _, tagTemplate := range docker.TagTemplates { - imageTemplate := fmt.Sprintf("%s:%s", docker.Image, tagTemplate) - // TODO: add overrides support to config - image, err := tmpl.New(ctx). - WithArtifact(artifact, map[string]string{}). - Apply(imageTemplate) - if err != nil { - return nil, errors.Wrapf(err, "failed to execute tag template '%s'", tagTemplate) - } - images = append(images, image) - } - return images, nil } diff --git a/internal/pipe/docker/docker_test.go b/internal/pipe/docker/docker_test.go index 0bd78749915..8f02330393a 100644 --- a/internal/pipe/docker/docker_test.go +++ b/internal/pipe/docker/docker_test.go @@ -152,47 +152,23 @@ func TestRunPipe(t *testing.T) { assertError: shouldNotErr, pubAssertError: shouldNotErr, }, - "with deprecated image name & tag templates": { + "multiple images with same extra file": { publish: true, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_run_pipe", + ImageTemplates: []string{ + registry + "goreleaser/multiplefiles1:latest", + }, Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", Binaries: []string{"mybin"}, - TagTemplates: []string{ - "{{.Tag}}-{{.Env.FOO}}", - }, - BuildFlagTemplates: []string{ - "--label=org.label-schema.version={{.Version}}", - }, - }, - }, - expect: []string{ - registry + "goreleaser/test_run_pipe:v1.0.0-123", - }, - assertImageLabels: shouldFindImagesWithLabels( - "goreleaser/test_run_pipe", - "label=org.label-schema.version=1.0.0", - ), - assertError: shouldNotErr, - pubAssertError: shouldNotErr, - }, - "multiple images with same extra file": { - publish: true, - dockers: []config.Docker{ - { - Image: registry + "goreleaser/multiplefiles1", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile", - Binaries: []string{"mybin"}, - TagTemplates: []string{"latest"}, - Files: []string{"testdata/extra_file.txt"}, + Files: []string{"testdata/extra_file.txt"}, }, { - Image: registry + "goreleaser/multiplefiles2", + ImageTemplates: []string{ + registry + "goreleaser/multiplefiles2:latest", + }, Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", @@ -213,20 +189,22 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_run_pipe", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile", - Binaries: []string{"mybin"}, - TagTemplates: []string{"latest"}, + ImageTemplates: []string{ + registry + "goreleaser/test_run_pipe:latest", + }, + Goos: "linux", + Goarch: "amd64", + Dockerfile: "testdata/Dockerfile", + Binaries: []string{"mybin"}, }, { - Image: registry + "goreleaser/test_run_pipe2", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile", - Binaries: []string{"mybin"}, - TagTemplates: []string{"latest"}, + ImageTemplates: []string{ + registry + "goreleaser/test_run_pipe2:latest", + }, + Goos: "linux", + Goarch: "amd64", + Dockerfile: "testdata/Dockerfile", + Binaries: []string{"mybin"}, }, }, assertImageLabels: noLabels, @@ -241,13 +219,14 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_run_pipe", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile", - Binaries: []string{"mybin"}, - SkipPush: true, - TagTemplates: []string{"latest"}, + ImageTemplates: []string{ + registry + "goreleaser/test_run_pipe:latest", + }, + Goos: "linux", + Goarch: "amd64", + Dockerfile: "testdata/Dockerfile", + Binaries: []string{"mybin"}, + SkipPush: true, }, }, expect: []string{ @@ -261,12 +240,13 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_run_pipe", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile", - Binaries: []string{"mybin"}, - TagTemplates: []string{"{{.Version}}"}, + ImageTemplates: []string{ + registry + "goreleaser/test_run_pipe:{{.Version}}", + }, + Goos: "linux", + Goarch: "amd64", + Dockerfile: "testdata/Dockerfile", + Binaries: []string{"mybin"}, }, }, expect: []string{ @@ -280,12 +260,13 @@ func TestRunPipe(t *testing.T) { publish: false, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_run_pipe", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile", - Binaries: []string{"mybin"}, - TagTemplates: []string{"latest"}, + ImageTemplates: []string{ + registry + "goreleaser/test_run_pipe:latest", + }, + Goos: "linux", + Goarch: "amd64", + Dockerfile: "testdata/Dockerfile", + Binaries: []string{"mybin"}, }, }, expect: []string{ @@ -299,12 +280,13 @@ func TestRunPipe(t *testing.T) { publish: false, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_build_args", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile", - Binaries: []string{"mybin"}, - TagTemplates: []string{"latest"}, + ImageTemplates: []string{ + registry + "goreleaser/test_build_args:latest", + }, + Goos: "linux", + Goarch: "amd64", + Dockerfile: "testdata/Dockerfile", + Binaries: []string{"mybin"}, BuildFlagTemplates: []string{ "--label=foo=bar", }, @@ -321,12 +303,13 @@ func TestRunPipe(t *testing.T) { publish: false, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_build_args", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile", - Binaries: []string{"mybin"}, - TagTemplates: []string{"latest"}, + ImageTemplates: []string{ + registry + "goreleaser/test_build_args:latest", + }, + Goos: "linux", + Goarch: "amd64", + Dockerfile: "testdata/Dockerfile", + Binaries: []string{"mybin"}, BuildFlagTemplates: []string{ "--bad-flag", }, @@ -339,12 +322,13 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: registry + "goreleaser/bad_dockerfile", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile.bad", - Binaries: []string{"mybin"}, - TagTemplates: []string{"latest"}, + ImageTemplates: []string{ + registry + "goreleaser/bad_dockerfile:latest", + }, + Goos: "linux", + Goarch: "amd64", + Dockerfile: "testdata/Dockerfile.bad", + Binaries: []string{"mybin"}, }, }, assertImageLabels: noLabels, @@ -354,14 +338,13 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_run_pipe", + ImageTemplates: []string{ + registry + "goreleaser/test_run_pipe:{{.Tag}", + }, Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", Binaries: []string{"mybin"}, - TagTemplates: []string{ - "{{.Tag}", - }, }, }, assertImageLabels: noLabels, @@ -371,12 +354,13 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_run_pipe", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile", - Binaries: []string{"mybin"}, - TagTemplates: []string{"latest"}, + ImageTemplates: []string{ + registry + "goreleaser/test_run_pipe:latest", + }, + Goos: "linux", + Goarch: "amd64", + Dockerfile: "testdata/Dockerfile", + Binaries: []string{"mybin"}, BuildFlagTemplates: []string{ "--label=tag={{.Tag}", }, @@ -389,14 +373,13 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_run_pipe", + ImageTemplates: []string{ + registry + "goreleaser/test_run_pipe:{{.Env.NOPE}}", + }, Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", Binaries: []string{"mybin"}, - TagTemplates: []string{ - "{{.Env.NOPE}}", - }, }, }, assertImageLabels: noLabels, @@ -406,12 +389,13 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: registry + "goreleaser/test_run_pipe", - Goos: "linux", - Goarch: "amd64", - Dockerfile: "testdata/Dockerfile", - Binaries: []string{"mybin"}, - TagTemplates: []string{"latest"}, + ImageTemplates: []string{ + registry + "goreleaser/test_run_pipe:latest", + }, + Goos: "linux", + Goarch: "amd64", + Dockerfile: "testdata/Dockerfile", + Binaries: []string{"mybin"}, BuildFlagTemplates: []string{ "--label=nope={{.Env.NOPE}}", }, @@ -424,16 +408,15 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: registry + "goreleaser/{{.ProjectName}}", + ImageTemplates: []string{ + registry + "goreleaser/{{.ProjectName}}:{{.Tag}}-{{.Env.FOO}}", + registry + "goreleaser/{{.ProjectName}}:latest", + }, Goos: "linux", Goarch: "amd64", Dockerfile: "testdata/Dockerfile", Binaries: []string{"mybin"}, SkipPush: true, - TagTemplates: []string{ - "{{.Tag}}-{{.Env.FOO}}", - "latest", - }, }, }, expect: []string{ @@ -448,12 +431,11 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: "docker.io/nope", - Goos: "linux", - Goarch: "amd64", - Binaries: []string{"mybin"}, - Dockerfile: "testdata/Dockerfile", - TagTemplates: []string{"latest"}, + ImageTemplates: []string{"docker.io/nope:latest"}, + Goos: "linux", + Goarch: "amd64", + Binaries: []string{"mybin"}, + Dockerfile: "testdata/Dockerfile", }, }, expect: []string{ @@ -467,12 +449,11 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: "whatever", - Goos: "linux", - Goarch: "amd64", - Binaries: []string{"mybin"}, - Dockerfile: "testdata/Dockerfilezzz", - TagTemplates: []string{"latest"}, + ImageTemplates: []string{"whatever:latest"}, + Goos: "linux", + Goarch: "amd64", + Binaries: []string{"mybin"}, + Dockerfile: "testdata/Dockerfilezzz", }, }, assertImageLabels: noLabels, @@ -482,12 +463,11 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: "whatever", - Goos: "linux", - Goarch: "amd64", - Binaries: []string{"mybin"}, - Dockerfile: "testdata/Dockerfile", - TagTemplates: []string{"latest"}, + ImageTemplates: []string{"whatever:latest"}, + Goos: "linux", + Goarch: "amd64", + Binaries: []string{"mybin"}, + Dockerfile: "testdata/Dockerfile", Files: []string{ "testdata/nope.txt", }, @@ -500,34 +480,35 @@ func TestRunPipe(t *testing.T) { publish: true, dockers: []config.Docker{ { - Image: "whatever", - Goos: "darwin", - Goarch: "amd64", - Binaries: []string{"mybinnnn"}, - Dockerfile: "testdata/Dockerfile", + ImageTemplates: []string{"whatever:latest"}, + Goos: "darwin", + Goarch: "amd64", + Binaries: []string{"mybinnnn"}, + Dockerfile: "testdata/Dockerfile", }, }, assertImageLabels: noLabels, - assertError: shouldErr(`0 binaries match docker definition: mybinnnn: darwin_amd64_`), + assertError: shouldErr(`0 binaries match docker definition: [mybinnnn]: darwin_amd64_, should be 1`), }, - "mixed image and image template": { + "multiple_binaries": { publish: true, dockers: []config.Docker{ { - ImageTemplates: []string{ - registry + "goreleaser/test_run_pipe:latest", - }, - Image: registry + "goreleaser/test_run_pipe", - Goos: "darwin", - Goarch: "amd64", - Binaries: []string{"mybin"}, - Dockerfile: "testdata/Dockerfile", - TagTemplates: []string{"latest"}, + ImageTemplates: []string{registry + "goreleaser/multiple:latest"}, + Goos: "darwin", + Goarch: "amd64", + Binaries: []string{"mybin", "anotherbin"}, + Dockerfile: "testdata/Dockerfile.multiple", }, }, assertImageLabels: noLabels, - assertError: shouldErr("failed to process image, use either image_templates (preferred) or image, not both"), + assertError: shouldNotErr, + pubAssertError: shouldNotErr, + expect: []string{ + registry + "goreleaser/multiple:latest", + }, }, + // TODO: add a test case for multiple matching binaries for the same name } killAndRm(t) @@ -541,8 +522,9 @@ func TestRunPipe(t *testing.T) { var dist = filepath.Join(folder, "dist") 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) + _, err = os.Create(filepath.Join(dist, "mybin", "mybin")) + require.NoError(tt, err) + _, err = os.Create(filepath.Join(dist, "mybin", "anotherbin")) require.NoError(tt, err) var ctx = context.New(config.Project{ @@ -561,16 +543,18 @@ func TestRunPipe(t *testing.T) { } for _, os := range []string{"linux", "darwin"} { for _, arch := range []string{"amd64", "386"} { - ctx.Artifacts.Add(artifact.Artifact{ - Name: "mybin", - Path: binPath, - Goarch: arch, - Goos: os, - Type: artifact.Binary, - Extra: map[string]interface{}{ - "Binary": "mybin", - }, - }) + for _, bin := range []string{"mybin", "anotherbin"} { + ctx.Artifacts.Add(artifact.Artifact{ + Name: bin, + Path: filepath.Join(dist, "mybin", bin), + Goarch: arch, + Goos: os, + Type: artifact.Binary, + Extra: map[string]interface{}{ + "Binary": bin, + }, + }) + } } } @@ -665,7 +649,7 @@ func TestDockerNotInPath(t *testing.T) { Config: config.Project{ Dockers: []config.Docker{ { - Image: "a/b", + ImageTemplates: []string{"a/b"}, }, }, }, @@ -699,7 +683,7 @@ func TestDefaultBinaries(t *testing.T) { Config: config.Project{ Dockers: []config.Docker{ { - Binaries: []string{"foo"}, + Binary: "foo", }, }, }, @@ -740,7 +724,7 @@ func TestDefaultSet(t *testing.T) { var docker = ctx.Config.Dockers[0] assert.Equal(t, "windows", docker.Goos) assert.Equal(t, "i386", docker.Goarch) - assert.Equal(t, "bar", docker.Binary) + assert.Equal(t, "bar", docker.Binaries[0]) assert.Equal(t, "Dockerfile.foo", docker.Dockerfile) } @@ -763,69 +747,52 @@ func TestDefaultWithImage(t *testing.T) { var docker = ctx.Config.Dockers[0] assert.Equal(t, "windows", docker.Goos) assert.Equal(t, "i386", docker.Goarch) - assert.Equal(t, "bar", docker.Binary) + assert.Equal(t, "bar", docker.Binaries[0]) assert.Equal(t, []string{"{{ .Version }}"}, docker.TagTemplates) assert.Equal(t, "Dockerfile.foo", docker.Dockerfile) + assert.Equal(t, []string{"my/image:{{ .Version }}"}, docker.ImageTemplates) } func Test_processImageTemplates(t *testing.T) { - - var table = map[string]struct { - image string - tagTemplates []string - imageTemplates []string - expectImages []string - }{ - "with image templates": { - imageTemplates: []string{"user/image:{{.Tag}}", "gcr.io/image:{{.Tag}}-{{.Env.FOO}}", "gcr.io/image:v{{.Major}}.{{.Minor}}"}, - expectImages: []string{"user/image:v1.0.0", "gcr.io/image:v1.0.0-123", "gcr.io/image:v1.0"}, - }, - "with image name and tag template": { - image: "my/image", - tagTemplates: []string{"{{.Tag}}-{{.Env.FOO}}", "v{{.Major}}.{{.Minor}}"}, - expectImages: []string{"my/image:v1.0.0-123", "my/image:v1.0"}, - }, - } - - for name, tt := range table { - t.Run(name, func(t *testing.T) { - - var ctx = &context.Context{ - Config: config.Project{ - Dockers: []config.Docker{ - { - Binaries: []string{"foo"}, - Image: tt.image, - Dockerfile: "Dockerfile.foo", - ImageTemplates: tt.imageTemplates, - SkipPush: true, - TagTemplates: tt.tagTemplates, - }, + var ctx = &context.Context{ + Config: config.Project{ + Dockers: []config.Docker{ + { + Binaries: []string{"foo"}, + Dockerfile: "Dockerfile.foo", + ImageTemplates: []string{ + "user/image:{{.Tag}}", + "gcr.io/image:{{.Tag}}-{{.Env.FOO}}", + "gcr.io/image:v{{.Major}}.{{.Minor}}", }, + SkipPush: true, }, - } - ctx.SkipPublish = true - ctx.Env = map[string]string{ - "FOO": "123", - } - ctx.Version = "1.0.0" - ctx.Git = context.GitInfo{ - CurrentTag: "v1.0.0", - Commit: "a1b2c3d4", - } - - assert.NoError(t, Pipe{}.Default(ctx)) - assert.Len(t, ctx.Config.Dockers, 1) + }, + }, + } + ctx.SkipPublish = true + ctx.Env = map[string]string{ + "FOO": "123", + } + ctx.Version = "1.0.0" + ctx.Git = context.GitInfo{ + CurrentTag: "v1.0.0", + Commit: "a1b2c3d4", + } - docker := ctx.Config.Dockers[0] - assert.Equal(t, "Dockerfile.foo", docker.Dockerfile) + assert.NoError(t, Pipe{}.Default(ctx)) + assert.Len(t, ctx.Config.Dockers, 1) - images, err := processImageTemplates(ctx, docker, artifact.Artifact{}) - assert.NoError(t, err) - assert.Equal(t, tt.expectImages, images) - }) - } + docker := ctx.Config.Dockers[0] + assert.Equal(t, "Dockerfile.foo", docker.Dockerfile) + images, err := processImageTemplates(ctx, docker, []artifact.Artifact{}) + assert.NoError(t, err) + assert.Equal(t, []string{ + "user/image:v1.0.0", + "gcr.io/image:v1.0.0-123", + "gcr.io/image:v1.0", + }, images) } func TestLinkFile(t *testing.T) { diff --git a/internal/pipe/docker/testdata/Dockerfile.bad b/internal/pipe/docker/testdata/Dockerfile.bad index 9151f88ba8a..5d9c5a30282 100644 --- a/internal/pipe/docker/testdata/Dockerfile.bad +++ b/internal/pipe/docker/testdata/Dockerfile.bad @@ -1,3 +1,2 @@ FROM nope ADD mybin / - diff --git a/internal/pipe/docker/testdata/Dockerfile.multiple b/internal/pipe/docker/testdata/Dockerfile.multiple new file mode 100644 index 00000000000..465c956770b --- /dev/null +++ b/internal/pipe/docker/testdata/Dockerfile.multiple @@ -0,0 +1,3 @@ +FROM scratch +ADD mybin / +ADD anotherbin / From 9df63c06710e78f186b571dd0af62cdea83dab22 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 11 Jan 2019 00:27:08 -0200 Subject: [PATCH 4/7] fix: tag templates --- internal/pipe/docker/docker.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/pipe/docker/docker.go b/internal/pipe/docker/docker.go index de505ec5140..56e353b0800 100644 --- a/internal/pipe/docker/docker.go +++ b/internal/pipe/docker/docker.go @@ -172,7 +172,7 @@ func process(ctx *context.Context, docker config.Docker, bins []artifact.Artifac } } - buildFlags, err := processBuildFlagTemplates(ctx, docker, bins[0]) + buildFlags, err := processBuildFlagTemplates(ctx, docker, bins) if err != nil { return err } @@ -204,6 +204,7 @@ func processImageTemplates(ctx *context.Context, docker config.Docker, artifacts for _, imageTemplate := range docker.ImageTemplates { // TODO: add overrides support to config var t = tmpl.New(ctx) + // TODO: add a test case and document this if len(artifacts) == 1 { t = t.WithArtifact(artifacts[0], map[string]string{}) } @@ -218,13 +219,16 @@ func processImageTemplates(ctx *context.Context, docker config.Docker, artifacts return images, nil } -func processBuildFlagTemplates(ctx *context.Context, docker config.Docker, artifact artifact.Artifact) ([]string, error) { +func processBuildFlagTemplates(ctx *context.Context, docker config.Docker, artifacts []artifact.Artifact) ([]string, error) { // nolint:prealloc var buildFlags []string for _, buildFlagTemplate := range docker.BuildFlagTemplates { - buildFlag, err := tmpl.New(ctx). - WithArtifact(artifact, map[string]string{}). - Apply(buildFlagTemplate) + var t = tmpl.New(ctx) + // TODO: add a test case and document this + if len(artifacts) == 1 { + t = t.WithArtifact(artifacts[0], map[string]string{}) + } + buildFlag, err := t.Apply(buildFlagTemplate) if err != nil { return nil, errors.Wrapf(err, "failed to process build flag template '%s'", buildFlagTemplate) } From f28c748a2a6ed5f16104b3ba22cfe66d71cd6956 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 11 Jan 2019 08:58:01 -0200 Subject: [PATCH 5/7] test: fix defaults test --- internal/pipe/defaults/defaults_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/pipe/defaults/defaults_test.go b/internal/pipe/defaults/defaults_test.go index 6738adae46e..43728571ff9 100644 --- a/internal/pipe/defaults/defaults_test.go +++ b/internal/pipe/defaults/defaults_test.go @@ -78,14 +78,16 @@ func TestFillPartial(t *testing.T) { }, }, Dockers: []config.Docker{ - {Image: "a/b"}, + { + ImageTemplates: []string{"a/b"}, + }, }, }, } assert.NoError(t, Pipe{}.Run(ctx)) assert.Len(t, ctx.Config.Archive.Files, 1) assert.Equal(t, `bin.install "testreleaser"`, ctx.Config.Brew.Install) - assert.NotEmpty(t, ctx.Config.Dockers[0].Binary) + assert.NotEmpty(t, ctx.Config.Dockers[0].Binaries) assert.NotEmpty(t, ctx.Config.Dockers[0].Goos) assert.NotEmpty(t, ctx.Config.Dockers[0].Goarch) assert.NotEmpty(t, ctx.Config.Dockers[0].Dockerfile) From cd1dddd00a49f514117fac9022b63d1360734673 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 11 Jan 2019 14:37:18 -0200 Subject: [PATCH 6/7] fix: breaking: remove .Binary, .Os, .Arch support from docker image_templates --- internal/pipe/docker/docker.go | 15 ++------------- internal/pipe/docker/docker_test.go | 4 ---- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/internal/pipe/docker/docker.go b/internal/pipe/docker/docker.go index 56e353b0800..f6092ba9327 100644 --- a/internal/pipe/docker/docker.go +++ b/internal/pipe/docker/docker.go @@ -202,13 +202,7 @@ func processImageTemplates(ctx *context.Context, docker config.Docker, artifacts // nolint:prealloc var images []string for _, imageTemplate := range docker.ImageTemplates { - // TODO: add overrides support to config - var t = tmpl.New(ctx) - // TODO: add a test case and document this - if len(artifacts) == 1 { - t = t.WithArtifact(artifacts[0], map[string]string{}) - } - image, err := t.Apply(imageTemplate) + image, err := tmpl.New(ctx).Apply(imageTemplate) if err != nil { return nil, errors.Wrapf(err, "failed to execute image template '%s'", imageTemplate) } @@ -223,12 +217,7 @@ func processBuildFlagTemplates(ctx *context.Context, docker config.Docker, artif // nolint:prealloc var buildFlags []string for _, buildFlagTemplate := range docker.BuildFlagTemplates { - var t = tmpl.New(ctx) - // TODO: add a test case and document this - if len(artifacts) == 1 { - t = t.WithArtifact(artifacts[0], map[string]string{}) - } - buildFlag, err := t.Apply(buildFlagTemplate) + buildFlag, err := tmpl.New(ctx).Apply(buildFlagTemplate) if err != nil { return nil, errors.Wrapf(err, "failed to process build flag template '%s'", buildFlagTemplate) } diff --git a/internal/pipe/docker/docker_test.go b/internal/pipe/docker/docker_test.go index 8f02330393a..aeff35693d0 100644 --- a/internal/pipe/docker/docker_test.go +++ b/internal/pipe/docker/docker_test.go @@ -104,13 +104,11 @@ func TestRunPipe(t *testing.T) { registry + "goreleaser/test_run_pipe:v{{.Major}}", registry + "goreleaser/test_run_pipe:v{{.Major}}.{{.Minor}}", registry + "goreleaser/test_run_pipe:commit-{{.Commit}}", - registry + "goreleaser/test_run_pipe:le-{{.Os}}", registry + "goreleaser/test_run_pipe:latest", altRegistry + "goreleaser/test_run_pipe:{{.Tag}}-{{.Env.FOO}}", altRegistry + "goreleaser/test_run_pipe:v{{.Major}}", altRegistry + "goreleaser/test_run_pipe:v{{.Major}}.{{.Minor}}", altRegistry + "goreleaser/test_run_pipe:commit-{{.Commit}}", - altRegistry + "goreleaser/test_run_pipe:le-{{.Os}}", altRegistry + "goreleaser/test_run_pipe:latest", }, Goos: "linux", @@ -134,13 +132,11 @@ func TestRunPipe(t *testing.T) { registry + "goreleaser/test_run_pipe:v1", registry + "goreleaser/test_run_pipe:v1.0", registry + "goreleaser/test_run_pipe:commit-a1b2c3d4", - registry + "goreleaser/test_run_pipe:le-linux", registry + "goreleaser/test_run_pipe:latest", altRegistry + "goreleaser/test_run_pipe:v1.0.0-123", altRegistry + "goreleaser/test_run_pipe:v1", altRegistry + "goreleaser/test_run_pipe:v1.0", altRegistry + "goreleaser/test_run_pipe:commit-a1b2c3d4", - altRegistry + "goreleaser/test_run_pipe:le-linux", altRegistry + "goreleaser/test_run_pipe:latest", }, assertImageLabels: shouldFindImagesWithLabels( From 9d66436959fd5a0552c1af407faecfea8230fe25 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 11 Jan 2019 14:50:50 -0200 Subject: [PATCH 7/7] fix: lint issues --- internal/pipe/docker/docker.go | 8 ++++---- internal/pipe/docker/docker_test.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/pipe/docker/docker.go b/internal/pipe/docker/docker.go index f6092ba9327..4c25339c31c 100644 --- a/internal/pipe/docker/docker.go +++ b/internal/pipe/docker/docker.go @@ -150,7 +150,7 @@ func process(ctx *context.Context, docker config.Docker, bins []artifact.Artifac } log.Debug("tempdir: " + tmp) - images, err := processImageTemplates(ctx, docker, bins) + images, err := processImageTemplates(ctx, docker) if err != nil { return err } @@ -172,7 +172,7 @@ func process(ctx *context.Context, docker config.Docker, bins []artifact.Artifac } } - buildFlags, err := processBuildFlagTemplates(ctx, docker, bins) + buildFlags, err := processBuildFlagTemplates(ctx, docker) if err != nil { return err } @@ -198,7 +198,7 @@ func process(ctx *context.Context, docker config.Docker, bins []artifact.Artifac return nil } -func processImageTemplates(ctx *context.Context, docker config.Docker, artifacts []artifact.Artifact) ([]string, error) { +func processImageTemplates(ctx *context.Context, docker config.Docker) ([]string, error) { // nolint:prealloc var images []string for _, imageTemplate := range docker.ImageTemplates { @@ -213,7 +213,7 @@ func processImageTemplates(ctx *context.Context, docker config.Docker, artifacts return images, nil } -func processBuildFlagTemplates(ctx *context.Context, docker config.Docker, artifacts []artifact.Artifact) ([]string, error) { +func processBuildFlagTemplates(ctx *context.Context, docker config.Docker) ([]string, error) { // nolint:prealloc var buildFlags []string for _, buildFlagTemplate := range docker.BuildFlagTemplates { diff --git a/internal/pipe/docker/docker_test.go b/internal/pipe/docker/docker_test.go index aeff35693d0..4a6fbeb1aa2 100644 --- a/internal/pipe/docker/docker_test.go +++ b/internal/pipe/docker/docker_test.go @@ -782,7 +782,7 @@ func Test_processImageTemplates(t *testing.T) { docker := ctx.Config.Dockers[0] assert.Equal(t, "Dockerfile.foo", docker.Dockerfile) - images, err := processImageTemplates(ctx, docker, []artifact.Artifact{}) + images, err := processImageTemplates(ctx, docker) assert.NoError(t, err) assert.Equal(t, []string{ "user/image:v1.0.0",