1
0
mirror of https://github.com/docker/compose.git synced 2025-04-07 19:55:07 +02:00

Merge pull request from ndeloof/build_secret_id

let user declare build secret target
This commit is contained in:
Guillaume Lours 2023-05-04 15:17:30 +02:00 committed by GitHub
commit 01afe5265e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions
pkg
compose
e2e/fixtures/build-test/secrets

@ -373,15 +373,19 @@ func addSecretsConfig(project *types.Project, service types.ServiceConfig) (sess
var sources []secretsprovider.Source
for _, secret := range service.Build.Secrets {
config := project.Secrets[secret.Source]
id := secret.Source
if secret.Target != "" {
id = secret.Target
}
switch {
case config.File != "":
sources = append(sources, secretsprovider.Source{
ID: secret.Source,
ID: id,
FilePath: config.File,
})
case config.Environment != "":
sources = append(sources, secretsprovider.Source{
ID: secret.Source,
ID: id,
Env: config.Environment,
})
default:

@ -22,5 +22,5 @@ RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret > /tmp/actual
RUN diff /tmp/expected /tmp/actual
RUN echo "bar" > /tmp/expected
RUN --mount=type=secret,id=envsecret cat /run/secrets/envsecret > tmp/actual
RUN --mount=type=secret,id=build_secret cat /run/secrets/build_secret > tmp/actual
RUN diff --ignore-all-space /tmp/expected /tmp/actual

@ -5,7 +5,8 @@ services:
context: .
secrets:
- mysecret
- envsecret
- source: envsecret
target: build_secret
secrets:
mysecret: