From 25e1cddc1b1198e89ed38f02ba2879447f765977 Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Wed, 6 Dec 2017 00:06:37 +0100 Subject: [PATCH] feat: allow env vars for docker tag_template Add env var support for the Docker tag_template field incl. test. --- pipeline/docker/docker.go | 2 ++ pipeline/docker/docker_test.go | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pipeline/docker/docker.go b/pipeline/docker/docker.go index 3bf1a18bc..88a2fad49 100644 --- a/pipeline/docker/docker.go +++ b/pipeline/docker/docker.go @@ -95,9 +95,11 @@ func tagName(ctx *context.Context, docker config.Docker) (string, error) { } data := struct { Version, Tag string + Env map[string]string }{ Version: ctx.Version, Tag: ctx.Git.CurrentTag, + Env: ctx.Env, } err = t.Execute(&out, data) return out.String(), err diff --git a/pipeline/docker/docker_test.go b/pipeline/docker/docker_test.go index 1f627ba0c..04d9348a7 100644 --- a/pipeline/docker/docker_test.go +++ b/pipeline/docker/docker_test.go @@ -53,7 +53,7 @@ func TestRunPipe(t *testing.T) { Dockerfile: "testdata/Dockerfile", Binary: "mybin", Latest: true, - TagTemplate: "{{.Tag}}", + TagTemplate: "{{.Tag}}-{{.Env.FOO}}", }, err: "", }, @@ -82,7 +82,7 @@ func TestRunPipe(t *testing.T) { }, } var images = []string{ - "localhost:5000/goreleaser/test_run_pipe:v1.0.0", + "localhost:5000/goreleaser/test_run_pipe:v1.0.0-123", "localhost:5000/goreleaser/test_run_pipe:latest", } // this might fail as the image doesnt exist yet, so lets ignore the error @@ -105,6 +105,7 @@ func TestRunPipe(t *testing.T) { docker.docker, }, }, + Env: map[string]string{"FOO": "123"}, } for _, plat := range []string{"linuxamd64", "linux386", "darwinamd64"} { ctx.AddBinary(plat, "mybin", "mybin", binPath)