Merge pull request #3352 from crazy-max/compose-pull-nocache

bake: pull and no-cache support for compose
This commit is contained in:
Tõnis Tiigi
2025-08-11 11:55:06 +03:00
committed by GitHub
2 changed files with 48 additions and 0 deletions
+12
View File
@@ -157,6 +157,16 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
return nil, err
}
var noCache *bool
if s.Build.NoCache {
noCache = &s.Build.NoCache
}
var pull *bool
if s.Build.Pull {
pull = &s.Build.Pull
}
g.Targets = append(g.Targets, targetName)
t := &Target{
Name: targetName,
@@ -183,6 +193,8 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
Ulimits: ulimits,
ExtraHosts: extraHosts,
Attest: attests,
NoCache: noCache,
Pull: pull,
}
if err = t.composeExtTarget(s.Build.Extensions); err != nil {
return nil, err
+36
View File
@@ -1073,6 +1073,42 @@ services:
require.Nil(t, attestMap["provenance"])
}
func TestParseComposePull(t *testing.T) {
dt := []byte(`
services:
app:
build:
context: .
pull: true
`)
c, err := ParseCompose([]composetypes.ConfigFile{{Content: dt}}, nil)
require.NoError(t, err)
require.Equal(t, 1, len(c.Targets))
target := c.Targets[0]
require.Equal(t, "app", target.Name)
require.Equal(t, true, *target.Pull)
}
func TestParseComposeNoCache(t *testing.T) {
dt := []byte(`
services:
app:
build:
context: .
no_cache: true
`)
c, err := ParseCompose([]composetypes.ConfigFile{{Content: dt}}, nil)
require.NoError(t, err)
require.Equal(t, 1, len(c.Targets))
target := c.Targets[0]
require.Equal(t, "app", target.Name)
require.Equal(t, true, *target.NoCache)
}
// chdir changes the current working directory to the named directory,
// and then restore the original working directory at the end of the test.
func chdir(t *testing.T, dir string) {