From c0c777aa7f7ec7f86f7f76d1f2ef47cee4c59da7 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:41:35 +0100 Subject: [PATCH] bake: additional test for print command and empty variable Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- bake/bake_test.go | 20 ++++++++++++++++++++ tests/bake.go | 31 ++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/bake/bake_test.go b/bake/bake_test.go index 0e76e0ef452f..1e4117eeb570 100644 --- a/bake/bake_test.go +++ b/bake/bake_test.go @@ -2008,3 +2008,23 @@ target "app" { require.Contains(t, err.Error(), "FOO must be greater than 5.") }) } + +// https://github.com/docker/buildx/issues/2822 +func TestVariableEmpty(t *testing.T) { + fp := File{ + Name: "docker-bake.hcl", + Data: []byte(` +variable "FOO" { + default = "" +} +target "app" { + output = [FOO] +} +`), + } + + ctx := context.TODO() + + _, _, err := ReadTargets(ctx, []File{fp}, []string{"app"}, nil, nil) + require.NoError(t, err) +} diff --git a/tests/bake.go b/tests/bake.go index 8f92cb8e668b..90e3bb1eba47 100644 --- a/tests/bake.go +++ b/tests/bake.go @@ -76,6 +76,20 @@ target "build" { args = { HELLO = "foo" } + cache-from = [ + "type=gha,scope=build", + "type=s3,region=eu-west-1,bucket=mybucket", + "user/repo:cache", + ] + cache-to = [ + "type=gha,scope=build,mode=max", + "type=s3,region=eu-west-1,bucket=mybucket", + "type=inline" + ] + output = [ + "./release-out", + "type=registry,ref=user/app" + ] } `)}, { @@ -104,6 +118,7 @@ RUN echo "Hello ${HELLO}" ) cmd := buildxCmd(sb, withDir(dir), withArgs("bake", "--print", "build")) + cmd.Env = append(cmd.Env, "AWS_ACCESS_KEY_ID=foo", "AWS_SECRET_ACCESS_KEY=bar") stdout := bytes.Buffer{} stderr := bytes.Buffer{} cmd.Stdout = &stdout @@ -140,7 +155,21 @@ RUN echo "Hello ${HELLO}" "dockerfile": "Dockerfile", "args": { "HELLO": "foo" - } + }, + "cache-from": [ + "type=gha,scope=build", + "type=s3,region=eu-west-1,bucket=mybucket", + "user/repo:cache", + ], + "cache-to": [ + "type=gha,scope=build,mode=max", + "type=s3,region=eu-west-1,bucket=mybucket", + "type=inline" + ], + "output": [ + "./release-out", + "type=registry,ref=user/app" + ] } } }