mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00
bake: check for empty build network with compose
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
e540bb03a4
commit
48977780ad
@ -102,6 +102,12 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
|
||||
shmSize = &shmSizeStr
|
||||
}
|
||||
|
||||
var networkModeP *string
|
||||
if s.Build.Network != "" {
|
||||
networkMode := s.Build.Network
|
||||
networkModeP = &networkMode
|
||||
}
|
||||
|
||||
var ulimits []string
|
||||
if s.Build.Ulimits != nil {
|
||||
for n, u := range s.Build.Ulimits {
|
||||
@ -154,7 +160,7 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
|
||||
})),
|
||||
CacheFrom: s.Build.CacheFrom,
|
||||
CacheTo: s.Build.CacheTo,
|
||||
NetworkMode: &s.Build.Network,
|
||||
NetworkMode: networkModeP,
|
||||
SSH: ssh,
|
||||
Secrets: secrets,
|
||||
ShmSize: shmSize,
|
||||
|
@ -63,22 +63,44 @@ var bakeTests = []func(t *testing.T, sb integration.Sandbox){
|
||||
}
|
||||
|
||||
func testBakePrint(t *testing.T, sb integration.Sandbox) {
|
||||
dockerfile := []byte(`
|
||||
FROM busybox
|
||||
ARG HELLO
|
||||
RUN echo "Hello ${HELLO}"
|
||||
`)
|
||||
bakefile := []byte(`
|
||||
testCases := []struct {
|
||||
name string
|
||||
f string
|
||||
dt []byte
|
||||
}{
|
||||
{
|
||||
"HCL",
|
||||
"docker-bake.hcl",
|
||||
[]byte(`
|
||||
target "build" {
|
||||
args = {
|
||||
HELLO = "foo"
|
||||
}
|
||||
}
|
||||
`)
|
||||
`)},
|
||||
{
|
||||
"Compose",
|
||||
"compose.yml",
|
||||
[]byte(`
|
||||
services:
|
||||
build:
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
HELLO: foo
|
||||
`)},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
dir := tmpdir(
|
||||
t,
|
||||
fstest.CreateFile("docker-bake.hcl", bakefile, 0600),
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
fstest.CreateFile(tc.f, tc.dt, 0600),
|
||||
fstest.CreateFile("Dockerfile", []byte(`
|
||||
FROM busybox
|
||||
ARG HELLO
|
||||
RUN echo "Hello ${HELLO}"
|
||||
`), 0600),
|
||||
)
|
||||
|
||||
cmd := buildxCmd(sb, withDir(dir), withArgs("bake", "--print", "build"))
|
||||
@ -123,6 +145,8 @@ target "build" {
|
||||
}
|
||||
}
|
||||
`, stdout.String())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func testBakeLocal(t *testing.T, sb integration.Sandbox) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user