From f036bba48ccc91acc6f7728710c2fcca6e3dfb0d Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 10 Feb 2021 19:04:29 -0800 Subject: [PATCH] bake: add test for json vars and attributes Signed-off-by: Tonis Tiigi --- bake/hcl_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bake/hcl_test.go b/bake/hcl_test.go index 55f46d12..70af0e3d 100644 --- a/bake/hcl_test.go +++ b/bake/hcl_test.go @@ -502,3 +502,14 @@ func TestHCLMultiFileAttrs(t *testing.T) { require.Equal(t, c.Targets[0].Name, "app") require.Equal(t, "pre-ghi", c.Targets[0].Args["v1"]) } + +func TestJSONAttributes(t *testing.T) { + dt := []byte(`{"FOO": "abc", "variable": {"BAR": {"default": "def"}}, "target": { "app": { "args": {"v1": "pre-${FOO}-${BAR}"}} } }`) + + c, err := ParseFile(dt, "docker-bake.json") + require.NoError(t, err) + + require.Equal(t, 1, len(c.Targets)) + require.Equal(t, c.Targets[0].Name, "app") + require.Equal(t, "pre-abc-def", c.Targets[0].Args["v1"]) +}