Skip to content

Commit e5a6b8e

Browse files
committed
bake: fix missing omitempty and optional tags for network field
Signed-off-by: CrazyMax <[email protected]> (cherry picked from commit 9fb8b04)
1 parent 78c8c28 commit e5a6b8e

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

bake/bake.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ type Target struct {
704704
Outputs []string `json:"output,omitempty" hcl:"output,optional" cty:"output"`
705705
Pull *bool `json:"pull,omitempty" hcl:"pull,optional" cty:"pull"`
706706
NoCache *bool `json:"no-cache,omitempty" hcl:"no-cache,optional" cty:"no-cache"`
707-
NetworkMode *string `json:"network" hcl:"network" cty:"network"`
707+
NetworkMode *string `json:"network,omitempty" hcl:"network,optional" cty:"network"`
708708
NoCacheFilter []string `json:"no-cache-filter,omitempty" hcl:"no-cache-filter,optional" cty:"no-cache-filter"`
709709
ShmSize *string `json:"shm-size,omitempty" hcl:"shm-size,optional"`
710710
Ulimits []string `json:"ulimits,omitempty" hcl:"ulimits,optional"`

tests/bake.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,26 @@ target "build" {
103103
require.Equal(t, ".", *def.Target["build"].Context)
104104
require.Equal(t, "Dockerfile", *def.Target["build"].Dockerfile)
105105
require.Equal(t, map[string]*string{"HELLO": ptrstr("foo")}, def.Target["build"].Args)
106+
107+
require.Equal(t, `{
108+
"group": {
109+
"default": {
110+
"targets": [
111+
"build"
112+
]
113+
}
114+
},
115+
"target": {
116+
"build": {
117+
"context": ".",
118+
"dockerfile": "Dockerfile",
119+
"args": {
120+
"HELLO": "foo"
121+
}
122+
}
123+
}
124+
}
125+
`, stdout.String())
106126
}
107127

108128
func testBakeLocal(t *testing.T, sb integration.Sandbox) {

0 commit comments

Comments
 (0)