From 9fb8b04b64d3908adfbaff7b4a716c0baf270918 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:32:06 +0200 Subject: [PATCH] bake: fix missing omitempty and optional tags for network field Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- bake/bake.go | 2 +- tests/bake.go | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bake/bake.go b/bake/bake.go index 9ed1dfd8..3a50f7b4 100644 --- a/bake/bake.go +++ b/bake/bake.go @@ -704,7 +704,7 @@ type Target struct { Outputs []string `json:"output,omitempty" hcl:"output,optional" cty:"output"` Pull *bool `json:"pull,omitempty" hcl:"pull,optional" cty:"pull"` NoCache *bool `json:"no-cache,omitempty" hcl:"no-cache,optional" cty:"no-cache"` - NetworkMode *string `json:"network" hcl:"network" cty:"network"` + NetworkMode *string `json:"network,omitempty" hcl:"network,optional" cty:"network"` NoCacheFilter []string `json:"no-cache-filter,omitempty" hcl:"no-cache-filter,optional" cty:"no-cache-filter"` ShmSize *string `json:"shm-size,omitempty" hcl:"shm-size,optional"` Ulimits []string `json:"ulimits,omitempty" hcl:"ulimits,optional"` diff --git a/tests/bake.go b/tests/bake.go index bafd4ba6..b4407a28 100644 --- a/tests/bake.go +++ b/tests/bake.go @@ -103,6 +103,26 @@ target "build" { require.Equal(t, ".", *def.Target["build"].Context) require.Equal(t, "Dockerfile", *def.Target["build"].Dockerfile) require.Equal(t, map[string]*string{"HELLO": ptrstr("foo")}, def.Target["build"].Args) + + require.Equal(t, `{ + "group": { + "default": { + "targets": [ + "build" + ] + } + }, + "target": { + "build": { + "context": ".", + "dockerfile": "Dockerfile", + "args": { + "HELLO": "foo" + } + } + } +} +`, stdout.String()) } func testBakeLocal(t *testing.T, sb integration.Sandbox) {