Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 4171f3d

Browse files
feat: add option to support buildx --label flag (#132)
1 parent fb64593 commit 4171f3d

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

_docs/data/data.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,8 @@ properties:
221221
description: Target platforms for build.
222222
type: list
223223
required: false
224+
225+
labels:
226+
description: Labels to add to the image.
227+
type: list
228+
required: false

cmd/drone-docker-buildx/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,5 +297,12 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
297297
Destination: &settings.Build.Platforms,
298298
Category: category,
299299
},
300+
&cli.StringSliceFlag{
301+
Name: "labels",
302+
EnvVars: []string{"PLUGIN_LABELS"},
303+
Usage: "labels to add to image",
304+
Destination: &settings.Build.Labels,
305+
Category: category,
306+
},
300307
}
301308
}

plugin/docker.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
123123
args = append(args, "-t", fmt.Sprintf("%s:%s", build.Repo, arg))
124124
}
125125

126+
for _, arg := range build.Labels.Value() {
127+
args = append(args, "--label", arg)
128+
}
129+
126130
return exec.Command(dockerExe, args...)
127131
}
128132

plugin/impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type Build struct {
6161
Quiet bool // Docker build quiet
6262
Output string // Docker build output folder
6363
NamedContext cli.StringSlice // Docker build named context
64+
Labels cli.StringSlice // Docker build labels
6465
}
6566

6667
// Settings for the Plugin.

0 commit comments

Comments
 (0)