From a6caa67c6fe967f7e2db4cdefeb99ba6d8cb6621 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Fri, 30 Jan 2015 09:10:19 +0200 Subject: [PATCH 1/7] Be able to force docker to update the tags --- plugin/publish/docker.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/publish/docker.go b/plugin/publish/docker.go index eda38e298..7cafb35b0 100644 --- a/plugin/publish/docker.go +++ b/plugin/publish/docker.go @@ -33,6 +33,7 @@ type Docker struct { KeepBuild bool `yaml:"keep_build"` Tag string `yaml:"tag"` Tags []string `yaml:"tags"` + ForceTags bool `yaml:"force_tags"` Condition *condition.Condition `yaml:"when,omitempty"` } @@ -100,7 +101,11 @@ func (d *Docker) Write(f *buildfile.Buildfile) { // Tag and push all tags for _, tag := range d.Tags { if tag != buildImageTag { - f.WriteCmd(fmt.Sprintf("docker tag %s:%s %s:%s", d.ImageName, buildImageTag, d.ImageName, tag)) + var options string + if d.ForceTags { + options = "-f" + } + f.WriteCmd(fmt.Sprintf("docker tag %s %s:%s %s:%s", options, d.ImageName, buildImageTag, d.ImageName, tag)) } f.WriteCmd(fmt.Sprintf("docker push %s:%s", d.ImageName, tag)) From 4b59896f4cf1bf137cce681dcb1ea5cf06d1906f Mon Sep 17 00:00:00 2001 From: Alvaro Date: Fri, 30 Jan 2015 10:07:55 +0200 Subject: [PATCH 2/7] Fix the tests. Not very elegant, but now the strings have an extra space to allow putting the options there. --- plugin/publish/docker_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/publish/docker_test.go b/plugin/publish/docker_test.go index a23797b5e..915d28f83 100644 --- a/plugin/publish/docker_test.go +++ b/plugin/publish/docker_test.go @@ -214,7 +214,7 @@ func TestTagsNoSingle(t *testing.T) { if !strings.Contains(response, "docker build --pull -t username/image:release-0.2") { t.Fatalf("Response: " + response + " isn't tagging images using our first custom tag\n\n") } - if !strings.Contains(response, "docker tag username/image:release-0.2 username/image:release-latest") { + if !strings.Contains(response, "docker tag username/image:release-0.2 username/image:release-latest") { t.Fatalf("Response: " + response + " isn't tagging images using our second custom tag\n\n") } if !strings.Contains(response, "docker push username/image:release-0.2") { @@ -256,10 +256,10 @@ func TestTagsWithSingle(t *testing.T) { if !strings.Contains(response, "docker build --pull -t username/image:release-0.3") { t.Fatalf("Response: " + response + " isn't tagging images using our first custom tag\n\n") } - if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-0.2") { + if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-0.2") { t.Fatalf("Response: " + response + " isn't tagging images using our second custom tag\n\n") } - if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-latest") { + if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-latest") { t.Fatalf("Response: " + response + " isn't tagging images using our third custom tag\n\n") } if !strings.Contains(response, "docker push username/image:release-0.2") { From 26fd14a8ccb345f62d2de59184928668c5e6581b Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 6 Feb 2015 22:38:08 -0800 Subject: [PATCH 3/7] added embedded proxy --- shared/build/proxy/proxy.go | 13 +++++++++++-- shared/build/proxy/proxy_test.go | 11 +++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/shared/build/proxy/proxy.go b/shared/build/proxy/proxy.go index 55ef9a11c..bad544ce0 100644 --- a/shared/build/proxy/proxy.go +++ b/shared/build/proxy/proxy.go @@ -5,14 +5,22 @@ import ( "fmt" ) -// bash header -const header = "#!/bin/bash\n" +// bash header plus an embedded perl script that can be used +// as an alternative to socat to proxy tcp traffic. +const header = `#!/bin/bash +set +e +echo H4sICGKv1VQAA3NvY2F0LnBsAH1SXUvDQBB8Tn7FipUmkpr6gWBKgyIiBdGixVeJ6RZP00u4S6wi8be7t3exFsWEhNzO7M7MXba34kar+FHIuEJV+I1GmNwkyV2Zv2A9Wq+xwJzWfk/IqqlhDM+lkEEf+tHp2e3lfTj6Rj5hGc/Op4Oryd3s4joJ9nbDaFGqF6Air/gVU0M2nyua1Dug76pUZmrvkDSW79ATpUZTWIsPUomrkQF3NLt7WGaVY2tUr6g6OqNJMrm+mHFT4HtXZZ4VZ6yXQn+4x3c/csCUxVNgF1S8RcrdsfcNS+gapWdWw6HPYY2/QUoRAqdOVX/1JAqEYD+ED9+j0MDm2A8EXU+eyQeF2ZxJnlgQ4ijjcRfFYp5pzwuBkvfGQiSa51jRYTiCwmVZ4z/h6Zoiqi4Q73v0Xd4Ib6ohT95IaD38AVhtB6yP5cN1tMa25fym2DpTLNtQWnqwoL+O80t8q6GRBWoN+EaHoGFjhP1uf2/Fv6zHZrFA9aMpm69bBql+16YUOF4ER8OTYxfRCjBnpUSNHSl03lu/9b8ACaSZylQDAAA= | base64 -d | gunzip > /tmp/socat && chmod +x /tmp/socat +` // this command string will check if the socat utility // exists, and if it does, will proxy connections to // the external IP address. const command = "[ -x /usr/bin/socat ] && socat TCP-LISTEN:%s,fork TCP:%s:%s &\n" +// alternative command that acts as a "polyfill" for socat +// in the event that it isn't installed on the server +const polyfill = "[ -x /tmp/socat ] && /tmp/socat TCP-LISTEN:%s,fork TCP:%s:%s &\n" + // Proxy stores proxy configuration details mapping // a local port to an external IP address with the // same port number. @@ -29,6 +37,7 @@ func (p Proxy) String() string { buf.WriteString(header) for port, ip := range p { buf.WriteString(fmt.Sprintf(command, port, ip, port)) + buf.WriteString(fmt.Sprintf(polyfill, port, ip, port)) } return buf.String() diff --git a/shared/build/proxy/proxy_test.go b/shared/build/proxy/proxy_test.go index 5e3ab54ac..4b431fe42 100644 --- a/shared/build/proxy/proxy_test.go +++ b/shared/build/proxy/proxy_test.go @@ -12,19 +12,18 @@ func TestProxy(t *testing.T) { p.Set("8080", "172.1.4.5") b := p.Bytes() - expected := `#!/bin/bash -[ -x /usr/bin/socat ] && socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 & + expected := header + `[ -x /usr/bin/socat ] && socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 & +[ -x /tmp/socat ] && /tmp/socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 & ` if string(b) != expected { - t.Errorf("Invalid proxy \n%s", expected) + t.Errorf("AInvalid proxy \n%s", string(b)) } // test creating a proxy script when there // are no proxy addresses added to the map p = Proxy{} b = p.Bytes() - expected = "#!/bin/bash\n" - if string(b) != expected { - t.Errorf("Invalid proxy \n%s", expected) + if string(b) != header { + t.Errorf("Invalid empty proxy file. Expected\n%s", header) } } From 90d9c7d301522b5e2db26175f20dd5274ec86a6f Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 6 Feb 2015 23:29:50 -0800 Subject: [PATCH 4/7] perl tcp proxy tests --- shared/build/proxy/proxy_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/build/proxy/proxy_test.go b/shared/build/proxy/proxy_test.go index 4b431fe42..a5f465aec 100644 --- a/shared/build/proxy/proxy_test.go +++ b/shared/build/proxy/proxy_test.go @@ -16,7 +16,7 @@ func TestProxy(t *testing.T) { [ -x /tmp/socat ] && /tmp/socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 & ` if string(b) != expected { - t.Errorf("AInvalid proxy \n%s", string(b)) + t.Errorf("Invalid proxy \n%s", string(b)) } // test creating a proxy script when there From 31b2c806e71284c1f480526c11dfade0131a6f06 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 20 Feb 2015 17:33:44 -0800 Subject: [PATCH 5/7] peg version of Docker --- .drone.yml | 5 ++++- Makefile | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5a4e09642..182432e57 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,10 +5,13 @@ env: - GOROOT=/usr/local/go - PATH=$PATH:$GOROOT/bin:$GOPATH/bin script: + - sudo add-apt-repository ppa:git-core/ppa 1> /dev/null 2> /dev/null - sudo apt-get update 1> /dev/null 2> /dev/null - - sudo apt-get -y install zip libsqlite3-dev sqlite3 rpm 1> /dev/null 2> /dev/null + - sudo apt-get update 1> /dev/null 2> /dev/null + - sudo apt-get -y install git zip libsqlite3-dev sqlite3 rpm 1> /dev/null 2> /dev/null - gem install fpm - rbenv rehash + - make docker - make deps - make test - make test_postgres diff --git a/Makefile b/Makefile index e24c3e709..fe35faefe 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,13 @@ ITTERATION := $(shell date +%s) all: build deps: - # which npm && npm -g install uglify-js less autoprefixer go get github.com/GeertJohan/go.rice/rice go get -t -v ./... +docker: + mkdir -p $$GOPATH/src/github.com/docker/docker + git clone --depth=1 --branch=v1.5.0 git://github.com/docker/docker.git $$GOPATH/src/github.com/docker/docker + test: @test -z "$(shell find . -name '*.go' | xargs gofmt -l)" || (echo "Need to run 'go fmt ./...'"; exit 1) go vet ./... From cd1fed3d5344d49f1e913f9b6c03ebd2296f8855 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 20 Feb 2015 17:41:32 -0800 Subject: [PATCH 6/7] backing out change to perl script proxy --- shared/build/proxy/proxy.go | 8 ++++++-- shared/build/proxy/proxy_test.go | 6 ++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/shared/build/proxy/proxy.go b/shared/build/proxy/proxy.go index bad544ce0..7af6a9b7c 100644 --- a/shared/build/proxy/proxy.go +++ b/shared/build/proxy/proxy.go @@ -9,9 +9,11 @@ import ( // as an alternative to socat to proxy tcp traffic. const header = `#!/bin/bash set +e -echo H4sICGKv1VQAA3NvY2F0LnBsAH1SXUvDQBB8Tn7FipUmkpr6gWBKgyIiBdGixVeJ6RZP00u4S6wi8be7t3exFsWEhNzO7M7MXba34kar+FHIuEJV+I1GmNwkyV2Zv2A9Wq+xwJzWfk/IqqlhDM+lkEEf+tHp2e3lfTj6Rj5hGc/Op4Oryd3s4joJ9nbDaFGqF6Air/gVU0M2nyua1Dug76pUZmrvkDSW79ATpUZTWIsPUomrkQF3NLt7WGaVY2tUr6g6OqNJMrm+mHFT4HtXZZ4VZ6yXQn+4x3c/csCUxVNgF1S8RcrdsfcNS+gapWdWw6HPYY2/QUoRAqdOVX/1JAqEYD+ED9+j0MDm2A8EXU+eyQeF2ZxJnlgQ4ijjcRfFYp5pzwuBkvfGQiSa51jRYTiCwmVZ4z/h6Zoiqi4Q73v0Xd4Ib6ohT95IaD38AVhtB6yP5cN1tMa25fym2DpTLNtQWnqwoL+O80t8q6GRBWoN+EaHoGFjhP1uf2/Fv6zHZrFA9aMpm69bBql+16YUOF4ER8OTYxfRCjBnpUSNHSl03lu/9b8ACaSZylQDAAA= | base64 -d | gunzip > /tmp/socat && chmod +x /tmp/socat ` +// TODO(bradrydzewski) probably going to remove this +//echo H4sICGKv1VQAA3NvY2F0LnBsAH1SXUvDQBB8Tn7FipUmkpr6gWBKgyIiBdGixVeJ6RZP00u4S6wi8be7t3exFsWEhNzO7M7MXba34kar+FHIuEJV+I1GmNwkyV2Zv2A9Wq+xwJzWfk/IqqlhDM+lkEEf+tHp2e3lfTj6Rj5hGc/Op4Oryd3s4joJ9nbDaFGqF6Air/gVU0M2nyua1Dug76pUZmrvkDSW79ATpUZTWIsPUomrkQF3NLt7WGaVY2tUr6g6OqNJMrm+mHFT4HtXZZ4VZ6yXQn+4x3c/csCUxVNgF1S8RcrdsfcNS+gapWdWw6HPYY2/QUoRAqdOVX/1JAqEYD+ED9+j0MDm2A8EXU+eyQeF2ZxJnlgQ4ijjcRfFYp5pzwuBkvfGQiSa51jRYTiCwmVZ4z/h6Zoiqi4Q73v0Xd4Ib6ohT95IaD38AVhtB6yP5cN1tMa25fym2DpTLNtQWnqwoL+O80t8q6GRBWoN+EaHoGFjhP1uf2/Fv6zHZrFA9aMpm69bBql+16YUOF4ER8OTYxfRCjBnpUSNHSl03lu/9b8ACaSZylQDAAA= | base64 -d | gunzip > /tmp/socat && chmod +x /tmp/socat + // this command string will check if the socat utility // exists, and if it does, will proxy connections to // the external IP address. @@ -37,7 +39,9 @@ func (p Proxy) String() string { buf.WriteString(header) for port, ip := range p { buf.WriteString(fmt.Sprintf(command, port, ip, port)) - buf.WriteString(fmt.Sprintf(polyfill, port, ip, port)) + + // TODO(bradrydzewski) probably going to remove this + //buf.WriteString(fmt.Sprintf(polyfill, port, ip, port)) } return buf.String() diff --git a/shared/build/proxy/proxy_test.go b/shared/build/proxy/proxy_test.go index a5f465aec..1e2112515 100644 --- a/shared/build/proxy/proxy_test.go +++ b/shared/build/proxy/proxy_test.go @@ -12,11 +12,9 @@ func TestProxy(t *testing.T) { p.Set("8080", "172.1.4.5") b := p.Bytes() - expected := header + `[ -x /usr/bin/socat ] && socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 & -[ -x /tmp/socat ] && /tmp/socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 & -` + expected := header + "[ -x /usr/bin/socat ] && socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 &\n" if string(b) != expected { - t.Errorf("Invalid proxy \n%s", string(b)) + t.Errorf("Invalid proxy got:\n%s\nwant:\n%s", string(b), expected) } // test creating a proxy script when there From cfe50421dcf5260f3aa7908a7d4fcd26fafd3443 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 20 Feb 2015 17:44:43 -0800 Subject: [PATCH 7/7] remove typo in github status message --- plugin/notify/github/github.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/notify/github/github.go b/plugin/notify/github/github.go index b8eaa2afb..b1e5db3c2 100644 --- a/plugin/notify/github/github.go +++ b/plugin/notify/github/github.go @@ -24,7 +24,7 @@ const ( const ( DescPending = "this build is pending" - DescSuccess = "the build was succcessful" + DescSuccess = "the build was successful" DescFailure = "the build failed" DescError = "oops, something went wrong" )