fix: use buildx builder if provided

This commit is contained in:
Kamesh 2022-11-01 13:29:33 +05:30
parent 248b7a5b77
commit aa2eead79d
No known key found for this signature in database
GPG Key ID: 677FF1660AEF442C
4 changed files with 16 additions and 0 deletions

View File

@ -1,5 +1,10 @@
---
properties:
builder_name:
description: Buildx builder to use.
type: string
required: false
dry_run:
description: Disable docker push.
type: bool

View File

@ -9,6 +9,13 @@ import (
// settingsFlags has the cli.Flags for the plugin.Settings.
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "builder-name",
EnvVars: []string{"PLUGIN_BUILDER_NAME"},
Usage: "the buildx builder to use",
Destination: &settings.Build.BuilderName,
Category: category,
},
&cli.BoolFlag{
Name: "dry-run",
EnvVars: []string{"PLUGIN_DRY_RUN"},

View File

@ -75,6 +75,9 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
}
args = append(args, build.Context)
if build.BuilderName != "" {
args = append(args, "--builder-name", build.BuilderName)
}
if !dryrun && build.Output == "" && len(build.Tags.Value()) > 0 {
args = append(args, "--push")
}

View File

@ -63,6 +63,7 @@ type Build struct {
Output string // Docker build output folder
NamedContext cli.StringSlice // Docker build named context
Labels cli.StringSlice // Docker build labels
BuilderName string // Docker buildx builder
}
// Settings for the Plugin.