From 3edd750381e6f15b0298406323d3d96efa8ff7f2 Mon Sep 17 00:00:00 2001 From: Ronald van Zantvoort Date: Thu, 31 May 2018 17:21:36 +0200 Subject: [PATCH 1/3] Add support for non label-schema labels --- cmd/drone-docker/main.go | 6 ++++++ docker.go | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/drone-docker/main.go b/cmd/drone-docker/main.go index 243d86a..e5c583d 100644 --- a/cmd/drone-docker/main.go +++ b/cmd/drone-docker/main.go @@ -171,6 +171,11 @@ func main() { Usage: "docker repository", EnvVar: "PLUGIN_REPO", }, + cli.StringSliceFlag{ + Name: "Labels", + Usage: "labels", + EnvVar: "PLUGIN_LABELS", + }, cli.StringSliceFlag{ Name: "label-schema", Usage: "label-schema labels", @@ -242,6 +247,7 @@ func run(c *cli.Context) error { Pull: c.BoolT("pull-image"), Compress: c.Bool("compress"), Repo: c.String("repo"), + Labels: c.StringSlice("labels"), LabelSchema: c.StringSlice("label-schema"), NoCache: c.Bool("no-cache"), }, diff --git a/docker.go b/docker.go index 0a8bc83..cb31c29 100644 --- a/docker.go +++ b/docker.go @@ -49,7 +49,8 @@ type ( Pull bool // Docker build pull Compress bool // Docker build compress Repo string // Docker build repository - LabelSchema []string // Label schema map + LabelSchema []string // label-schema Label map + Labels []string // Label map NoCache bool // Docker build no-cache } @@ -214,6 +215,7 @@ func commandBuild(build Build) *exec.Cmd { } labelSchema := []string{ + "version=1.0", fmt.Sprintf("build-date=%s", time.Now().Format(time.RFC3339)), fmt.Sprintf("vcs-ref=%s", build.Name), fmt.Sprintf("vcs-url=%s", build.Remote), @@ -227,6 +229,12 @@ func commandBuild(build Build) *exec.Cmd { args = append(args, "--label", fmt.Sprintf("org.label-schema.%s", label)) } + if len(build.Labels) > 0 { + for _, label := range build.Labels { + args = append(args, "--label", label) + } + } + return exec.Command(dockerExe, args...) } From aa92ac1ef0160d85ed6d1f3e63a530fd3458523b Mon Sep 17 00:00:00 2001 From: Ronald van Zantvoort Date: Thu, 31 May 2018 17:31:29 +0200 Subject: [PATCH 2/3] its called schema-version --- docker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker.go b/docker.go index cb31c29..2596012 100644 --- a/docker.go +++ b/docker.go @@ -215,7 +215,7 @@ func commandBuild(build Build) *exec.Cmd { } labelSchema := []string{ - "version=1.0", + "schema-version=1.0", fmt.Sprintf("build-date=%s", time.Now().Format(time.RFC3339)), fmt.Sprintf("vcs-ref=%s", build.Name), fmt.Sprintf("vcs-url=%s", build.Remote), From ca44fcf4a170853484be1595ac6503f905a98457 Mon Sep 17 00:00:00 2001 From: Ronald van Zantvoort Date: Thu, 7 Jun 2018 01:43:53 +0200 Subject: [PATCH 3/3] arg fix for custom labels --- cmd/drone-docker/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/drone-docker/main.go b/cmd/drone-docker/main.go index e5c583d..4d746ca 100644 --- a/cmd/drone-docker/main.go +++ b/cmd/drone-docker/main.go @@ -172,9 +172,9 @@ func main() { EnvVar: "PLUGIN_REPO", }, cli.StringSliceFlag{ - Name: "Labels", - Usage: "labels", - EnvVar: "PLUGIN_LABELS", + Name: "custom-labels", + Usage: "additional k=v labels", + EnvVar: "PLUGIN_CUSTOM_LABELS", }, cli.StringSliceFlag{ Name: "label-schema", @@ -247,7 +247,7 @@ func run(c *cli.Context) error { Pull: c.BoolT("pull-image"), Compress: c.Bool("compress"), Repo: c.String("repo"), - Labels: c.StringSlice("labels"), + Labels: c.StringSlice("custom-labels"), LabelSchema: c.StringSlice("label-schema"), NoCache: c.Bool("no-cache"), },