let user declare build secret target (id)

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2023-05-04 10:01:10 +02:00
parent b304c4e154
commit b45ca82791
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
3 changed files with 9 additions and 4 deletions

View File

@ -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:

View File

@ -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

View File

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