From bcd29fc31f41ecb41d39e5b282da1625fac0d7fa Mon Sep 17 00:00:00 2001 From: Kyle Vigen Date: Wed, 25 Jun 2014 14:37:45 -0700 Subject: [PATCH] Also publish "latest" image --- pkg/plugin/publish/docker.go | 5 +++-- pkg/plugin/publish/docker_test.go | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/plugin/publish/docker.go b/pkg/plugin/publish/docker.go index e1a2638c1..417ac89dd 100644 --- a/pkg/plugin/publish/docker.go +++ b/pkg/plugin/publish/docker.go @@ -51,8 +51,9 @@ func (d *Docker) Write(f *buildfile.Buildfile, r *repo.Repo) { dockerServerUrl := d.Server + ":" + strconv.Itoa(d.Port) splitRepoName := strings.Split(r.Name, "/") dockerRepo := d.RepoBaseName + "/" + splitRepoName[len(splitRepoName) - 1] - // Run the command commands to build and deploy the image. Note that the image is tagged - // with the git hash. + // Run the command commands to build and deploy the image. Note that we both create a new image + // tagged with the git hash as well as update the "latest" image. + f.WriteCmd(fmt.Sprintf("docker -H %s build -t %s - < %s", dockerServerUrl, dockerRepo, d.Dockerfile)) f.WriteCmd(fmt.Sprintf("docker -H %s build -t %s:$(git rev-parse --short HEAD) - < %s", dockerServerUrl, dockerRepo, d.Dockerfile)) diff --git a/pkg/plugin/publish/docker_test.go b/pkg/plugin/publish/docker_test.go index 44271f719..6e6133114 100644 --- a/pkg/plugin/publish/docker_test.go +++ b/pkg/plugin/publish/docker_test.go @@ -58,9 +58,13 @@ func TestValidYaml(t *testing.T) { if err != nil { t.Fatalf("Can't unmarshal script: %s", err.Error()) } + + if !strings.Contains(response, "docker -H server:1000 build -t base_repo/name - <") { + t.Fatalf("Response: " + response + " doesn't contain build command for latest") + } if !strings.Contains(response, "docker -H server:1000 build -t base_repo/name" + ":$(git rev-parse --short HEAD)") { - t.Fatalf("Response: " + response + "doesn't contain build command") + t.Fatalf("Response: " + response + "doesn't contain build command for commit hash") } if !strings.Contains(response, "docker -H server:1000 login -u user -p password -e email") { t.Fatalf("Response: " + response + " doesn't contain login command")