mirror of https://github.com/docker/compose.git
let user declare build secret target (id)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
b304c4e154
commit
b45ca82791
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue