From 29dccc3dc37c70cd095075724c336a519dbd6bb2 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Sat, 18 Jun 2016 22:23:15 +0200 Subject: [PATCH 1/8] More logging, disable docker login email, changes to makefile --- Makefile | 3 ++- plugin.go | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3881d6f..a4526f7 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: all clean deps fmt vet test docker EXECUTABLE ?= drone-docker -IMAGE ?= plugins/$(EXECUTABLE) +IMAGE ?= plugins/docker COMMIT ?= $(shell git rev-parse --short HEAD) LDFLAGS = -X "main.buildCommit=$(COMMIT)" @@ -13,6 +13,7 @@ clean: go clean -i ./... deps: + go get -u github.com/codegangsta/cli/... go get -t ./... fmt: diff --git a/plugin.go b/plugin.go index ac94535..76704bf 100644 --- a/plugin.go +++ b/plugin.go @@ -95,11 +95,11 @@ func (p Plugin) Exec() error { cmds = append(cmds, commandVersion()) // docker version cmds = append(cmds, commandInfo()) // docker info cmds = append(cmds, commandBuild(p.Build)) // docker build - for _, tag := range p.Build.Tags { + fmt.Fprintf(os.Stdout, "Tagging: %s\n", tag) cmds = append(cmds, commandTag(p.Build, tag)) // docker tag - if p.Dryrun == false { + fmt.Fprintf(os.Stdout, "Pushing: %s\n", tag) cmds = append(cmds, commandPush(p.Build, tag)) // docker push } } @@ -123,11 +123,12 @@ const dockerExe = "/usr/local/bin/docker" // helper function to create the docker login command. func commandLogin(login Login) *exec.Cmd { + fmt.Fprintf(os.Stdout, "Logging in to registry: %s with user: %s and email: %s\n", login.Registry, login.Username, login.Email) return exec.Command( dockerExe, "login", "-u", login.Username, "-p", login.Password, - "-e", login.Email, + // "-e", login.Email, login.Registry, ) } From 57d0b5bcc553534a139239b663bc55c7e25713ac Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Sat, 18 Jun 2016 22:36:21 +0200 Subject: [PATCH 2/8] Remove logs, remove commented code --- plugin.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugin.go b/plugin.go index 76704bf..31a7d49 100644 --- a/plugin.go +++ b/plugin.go @@ -96,10 +96,8 @@ func (p Plugin) Exec() error { cmds = append(cmds, commandInfo()) // docker info cmds = append(cmds, commandBuild(p.Build)) // docker build for _, tag := range p.Build.Tags { - fmt.Fprintf(os.Stdout, "Tagging: %s\n", tag) cmds = append(cmds, commandTag(p.Build, tag)) // docker tag if p.Dryrun == false { - fmt.Fprintf(os.Stdout, "Pushing: %s\n", tag) cmds = append(cmds, commandPush(p.Build, tag)) // docker push } } @@ -123,12 +121,10 @@ const dockerExe = "/usr/local/bin/docker" // helper function to create the docker login command. func commandLogin(login Login) *exec.Cmd { - fmt.Fprintf(os.Stdout, "Logging in to registry: %s with user: %s and email: %s\n", login.Registry, login.Username, login.Email) return exec.Command( dockerExe, "login", "-u", login.Username, "-p", login.Password, - // "-e", login.Email, login.Registry, ) } From 4971855b4d31138d77b5bad4f0408aad2adf8881 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Sat, 18 Jun 2016 22:37:45 +0200 Subject: [PATCH 3/8] Remove codegangsta/cli from makefile deps (are already bundled in vendor) --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index a4526f7..05904e0 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,6 @@ clean: go clean -i ./... deps: - go get -u github.com/codegangsta/cli/... go get -t ./... fmt: From 87e0bec62f59c0420216ff3e20cae2a2e5ca9708 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Sat, 18 Jun 2016 22:38:38 +0200 Subject: [PATCH 4/8] Put newlines back --- plugin.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin.go b/plugin.go index 31a7d49..82143ea 100644 --- a/plugin.go +++ b/plugin.go @@ -95,8 +95,10 @@ func (p Plugin) Exec() error { cmds = append(cmds, commandVersion()) // docker version cmds = append(cmds, commandInfo()) // docker info cmds = append(cmds, commandBuild(p.Build)) // docker build + for _, tag := range p.Build.Tags { cmds = append(cmds, commandTag(p.Build, tag)) // docker tag + if p.Dryrun == false { cmds = append(cmds, commandPush(p.Build, tag)) // docker push } From cec1cb5d129589b879a33571d4d789fb9741ff0a Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Sat, 18 Jun 2016 22:56:22 +0200 Subject: [PATCH 5/8] Add email to login command when given --- plugin.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugin.go b/plugin.go index 82143ea..ed699a5 100644 --- a/plugin.go +++ b/plugin.go @@ -123,6 +123,9 @@ const dockerExe = "/usr/local/bin/docker" // helper function to create the docker login command. func commandLogin(login Login) *exec.Cmd { + if p.Login.Email != "" { + return commandLoginEmail(p.Login) + } return exec.Command( dockerExe, "login", "-u", login.Username, @@ -131,6 +134,16 @@ func commandLogin(login Login) *exec.Cmd { ) } +func commandLoginEmail(p.Login) *exec.Cmd { + return exec.Command( + dockerExe, "login", + "-u", login.Username, + "-p", login.Password, + "-e", login.Email, + login.Registry, + ) +} + // helper function to create the docker info command. func commandVersion() *exec.Cmd { return exec.Command(dockerExe, "version") From 284c8ef789ba7b4d1f3c3a3c991d22fdc12a6634 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Sat, 18 Jun 2016 23:13:45 +0200 Subject: [PATCH 6/8] Fix argument type --- plugin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.go b/plugin.go index ed699a5..09f3374 100644 --- a/plugin.go +++ b/plugin.go @@ -134,7 +134,7 @@ func commandLogin(login Login) *exec.Cmd { ) } -func commandLoginEmail(p.Login) *exec.Cmd { +func commandLoginEmail(login Login) *exec.Cmd { return exec.Command( dockerExe, "login", "-u", login.Username, From 65be2b6a3c6706d76591e232a2855c314611ca50 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Sat, 18 Jun 2016 23:15:03 +0200 Subject: [PATCH 7/8] Fix parameter value --- plugin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.go b/plugin.go index 09f3374..fafff76 100644 --- a/plugin.go +++ b/plugin.go @@ -124,7 +124,7 @@ const dockerExe = "/usr/local/bin/docker" // helper function to create the docker login command. func commandLogin(login Login) *exec.Cmd { if p.Login.Email != "" { - return commandLoginEmail(p.Login) + return commandLoginEmail(login) } return exec.Command( dockerExe, "login", From b751480d55d1f182b77214b1d6cff7427c922bc8 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Sat, 18 Jun 2016 23:24:57 +0200 Subject: [PATCH 8/8] Fix variable --- plugin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.go b/plugin.go index fafff76..73d6bac 100644 --- a/plugin.go +++ b/plugin.go @@ -123,7 +123,7 @@ const dockerExe = "/usr/local/bin/docker" // helper function to create the docker login command. func commandLogin(login Login) *exec.Cmd { - if p.Login.Email != "" { + if login.Email != "" { return commandLoginEmail(login) } return exec.Command(