From ee13dd891edc5956754f592d1c12d94ff178acc6 Mon Sep 17 00:00:00 2001 From: Martin Honermeyer Date: Thu, 27 Jan 2022 21:53:46 +0100 Subject: [PATCH] feat: add `output` option to set the export action for build results (#71) --- _docs/_index.md | 3 +++ cmd/drone-docker-buildx/config.go | 6 ++++++ plugin/docker.go | 5 ++++- plugin/impl.go | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/_docs/_index.md b/_docs/_index.md index 98c8f23..42b6ce6 100644 --- a/_docs/_index.md +++ b/_docs/_index.md @@ -142,6 +142,9 @@ pull_image compress : enables compression og the build context using gzip +output +: sets output folder for build artifacts (format: `path` or `type=TYPE[,KEY=VALUE]`) + repo : sets repository name for the image diff --git a/cmd/drone-docker-buildx/config.go b/cmd/drone-docker-buildx/config.go index 1b05ec9..ce407cd 100644 --- a/cmd/drone-docker-buildx/config.go +++ b/cmd/drone-docker-buildx/config.go @@ -150,6 +150,12 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag { Usage: "enables suppression of the build output", Destination: &settings.Build.Quiet, }, + &cli.StringFlag{ + Name: "output", + EnvVars: []string{"PLUGIN_OUTPUT"}, + Usage: "sets build output folder", + Destination: &settings.Build.Output, + }, &cli.StringFlag{ Name: "target", EnvVars: []string{"PLUGIN_TARGET"}, diff --git a/plugin/docker.go b/plugin/docker.go index d64f886..f1b7f7e 100644 --- a/plugin/docker.go +++ b/plugin/docker.go @@ -84,7 +84,7 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd { } args = append(args, build.Context) - if !dryrun && len(build.Tags.Value()) > 0 { + if !dryrun && build.Output == "" && len(build.Tags.Value()) > 0 { args = append(args, "--push") } if build.Compress { @@ -114,6 +114,9 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd { if build.Quiet { args = append(args, "--quiet") } + if build.Output != "" { + args = append(args, "--output", build.Output) + } if len(build.Platforms.Value()) > 0 { args = append(args, "--platform", strings.Join(build.Platforms.Value()[:], ",")) diff --git a/plugin/impl.go b/plugin/impl.go index 6128e0c..8f0b526 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -59,6 +59,7 @@ type Build struct { NoCache bool // Docker build no-cache AddHost cli.StringSlice // Docker build add-host Quiet bool // Docker build quiet + Output string // Docker build output folder } // Settings for the Plugin.