bake: pull and no-cache support for compose
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -163,6 +163,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,
|
||||
@@ -189,6 +199,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
|
||||
|
||||
@@ -1035,6 +1035,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) {
|
||||
|
||||
Reference in New Issue
Block a user