feat: add option to support buildx --label flag (#132)

This commit is contained in:
Richard Jennings 2022-09-20 20:35:29 +01:00 committed by GitHub
parent fb64593ea2
commit 4171f3d711
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 0 deletions

View File

@ -221,3 +221,8 @@ properties:
description: Target platforms for build.
type: list
required: false
labels:
description: Labels to add to the image.
type: list
required: false

View File

@ -297,5 +297,12 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
Destination: &settings.Build.Platforms,
Category: category,
},
&cli.StringSliceFlag{
Name: "labels",
EnvVars: []string{"PLUGIN_LABELS"},
Usage: "labels to add to image",
Destination: &settings.Build.Labels,
Category: category,
},
}
}

View File

@ -123,6 +123,10 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
args = append(args, "-t", fmt.Sprintf("%s:%s", build.Repo, arg))
}
for _, arg := range build.Labels.Value() {
args = append(args, "--label", arg)
}
return exec.Command(dockerExe, args...)
}

View File

@ -61,6 +61,7 @@ type Build struct {
Quiet bool // Docker build quiet
Output string // Docker build output folder
NamedContext cli.StringSlice // Docker build named context
Labels cli.StringSlice // Docker build labels
}
// Settings for the Plugin.