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

Commit a572b72

Browse files
authored
feat: add support for docker build secrets (#282)
1 parent 471b9e0 commit a572b72

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
@@ -265,3 +265,8 @@ properties:
265265
description: Generate [sbom](https://docs.docker.com/build/attestations/sbom/) attestation for the build (shorthand for `--attest type=sbom`).
266266
type: string
267267
required: false
268+
269+
- name: secrets
270+
description: Pass [secrets](https://docs.docker.com/engine/reference/commandline/buildx_build/#secret) when building.
271+
type: list
272+
required: false

cmd/drone-docker-buildx/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,5 +321,12 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
321321
Destination: &settings.Build.SBOM,
322322
Category: category,
323323
},
324+
&cli.StringSliceFlag{
325+
Name: "secrets",
326+
EnvVars: []string{"PLUGIN_SECRETS"},
327+
Usage: "secret key-value pairs",
328+
Destination: &settings.Build.Secrets,
329+
Category: category,
330+
},
324331
}
325332
}

plugin/docker.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ func commandBuild(build Build, dryrun bool) *execabs.Cmd {
160160
args = append(args, "--sbom", build.SBOM)
161161
}
162162

163+
for _, secret := range build.Secrets.Value() {
164+
args = append(args, "--secret", secret)
165+
}
166+
163167
return execabs.Command(dockerBin, args...)
164168
}
165169

plugin/impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ type Build struct {
6565
Labels cli.StringSlice // Docker build labels
6666
Provenance string // Docker build provenance attestation
6767
SBOM string // Docker build sbom attestation
68+
Secrets cli.StringSlice // Docker build secret key-pairs
6869
}
6970

7071
// Settings for the Plugin.

0 commit comments

Comments
 (0)