From e0350f671aeba148c3732bbdcc6476bedc041f43 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 14 Jun 2022 18:45:23 +0200 Subject: [PATCH] bake: support compose secrets env Signed-off-by: CrazyMax --- bake/compose.go | 3 +++ bake/compose_test.go | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bake/compose.go b/bake/compose.go index 78b1c0c9..d6b7f1fb 100644 --- a/bake/compose.go +++ b/bake/compose.go @@ -235,6 +235,9 @@ func composeToBuildkitSecret(inp compose.ServiceSecretConfig, psecret compose.Se if psecret.File != "" { bkattrs = append(bkattrs, "src="+psecret.File) } + if psecret.Environment != "" { + bkattrs = append(bkattrs, "env="+psecret.Environment) + } return strings.Join(bkattrs, ","), nil } diff --git a/bake/compose_test.go b/bake/compose_test.go index d9f88a48..0d28b36f 100644 --- a/bake/compose_test.go +++ b/bake/compose_test.go @@ -24,10 +24,11 @@ services: args: buildno: 123 secrets: - - ENV_TOKEN + - token - aws secrets: - ENV_TOKEN: {} + token: + environment: ENV_TOKEN aws: file: /root/.aws/credentials `) @@ -54,7 +55,7 @@ secrets: require.Equal(t, "123", c.Targets[1].Args["buildno"]) require.Equal(t, "none", *c.Targets[1].NetworkMode) require.Equal(t, []string{ - "id=ENV_TOKEN", + "id=token,env=ENV_TOKEN", "id=aws,src=/root/.aws/credentials", }, c.Targets[1].Secrets) }