fix secrets format

This commit is contained in:
gregoire78 2023-06-29 15:19:53 +02:00
parent c7c3ad6942
commit 9dcea580f2
No known key found for this signature in database
GPG Key ID: 44FAEC45FC701925
5 changed files with 17 additions and 9 deletions

View File

@ -112,7 +112,8 @@ steps:
from_secret: secure_token
settings:
secrets:
- "id=raw_file_secret,src=file.txt"
- "id=raw_file_secret\\\\,src=file.txt"
- 'id=other_raw_file_secret\\,src=other_file.txt'
- "id=SECRET_TOKEN"
```

View File

@ -321,12 +321,12 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
Destination: &settings.Build.SBOM,
Category: category,
},
&cli.StringSliceFlag{
Name: "secrets",
EnvVars: []string{"PLUGIN_SECRETS"},
Usage: "exposes secrets to the build",
Destination: &settings.Build.Secrets,
Category: category,
&cli.GenericFlag{
Name: "secrets",
EnvVars: []string{"PLUGIN_SECRETS"},
Usage: "exposes secrets to the build",
Value: &drone.StringSliceFlag{},
Category: category,
},
}
}

View File

@ -57,6 +57,13 @@ func run(settings *plugin.Settings) cli.ActionFunc {
settings.Build.CacheFrom = cacheFrom.Get()
secrets, ok := ctx.Generic("secrets").(*drone.StringSliceFlag)
if !ok {
return fmt.Errorf("%w: failed to read secrets input", ErrTypeAssertionFailed)
}
settings.Build.Secrets = secrets.Get()
plugin := plugin.New(
*settings,
urfave.PipelineFromContext(ctx),

View File

@ -160,7 +160,7 @@ func commandBuild(build Build, dryrun bool) *execabs.Cmd {
args = append(args, "--sbom", build.SBOM)
}
for _, secret := range build.Secrets.Value() {
for _, secret := range build.Secrets {
args = append(args, "--secret", secret)
}

View File

@ -65,7 +65,7 @@ type Build struct {
Labels cli.StringSlice // Docker build labels
Provenance string // Docker build provenance attestation
SBOM string // Docker build sbom attestation
Secrets cli.StringSlice // Docker build secrets
Secrets []string // Docker build secrets
}
// Settings for the Plugin.