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

Commit 89db4c2

Browse files
author
Grégoire Joncour
authored
fix: fix secrets format (#285)
1 parent c7c3ad6 commit 89db4c2

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

_docs/content/_index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ steps:
112112
from_secret: secure_token
113113
settings:
114114
secrets:
115-
- "id=raw_file_secret,src=file.txt"
115+
- "id=raw_file_secret\\\\,src=file.txt"
116+
- 'id=other_raw_file_secret\\,src=other_file.txt'
116117
- "id=SECRET_TOKEN"
117118
```
118119

cmd/drone-docker-buildx/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +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: "exposes secrets to the build",
328-
Destination: &settings.Build.Secrets,
329-
Category: category,
324+
&cli.GenericFlag{
325+
Name: "secrets",
326+
EnvVars: []string{"PLUGIN_SECRETS"},
327+
Usage: "exposes secrets to the build",
328+
Value: &drone.StringSliceFlag{},
329+
Category: category,
330330
},
331331
}
332332
}

cmd/drone-docker-buildx/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ func run(settings *plugin.Settings) cli.ActionFunc {
5757

5858
settings.Build.CacheFrom = cacheFrom.Get()
5959

60+
secrets, ok := ctx.Generic("secrets").(*drone.StringSliceFlag)
61+
if !ok {
62+
return fmt.Errorf("%w: failed to read secrets input", ErrTypeAssertionFailed)
63+
}
64+
65+
settings.Build.Secrets = secrets.Get()
66+
6067
plugin := plugin.New(
6168
*settings,
6269
urfave.PipelineFromContext(ctx),

plugin/docker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func commandBuild(build Build, dryrun bool) *execabs.Cmd {
160160
args = append(args, "--sbom", build.SBOM)
161161
}
162162

163-
for _, secret := range build.Secrets.Value() {
163+
for _, secret := range build.Secrets {
164164
args = append(args, "--secret", secret)
165165
}
166166

plugin/impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +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 secrets
68+
Secrets []string // Docker build secrets
6969
}
7070

7171
// Settings for the Plugin.

0 commit comments

Comments
 (0)