1
0
Fork 0

refactor: cache control for the container module

timestamps
dump_stack() 2023-05-29 09:09:30 +00:00
parent 004d4223f9
commit ca57ea2dac
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
2 changed files with 4 additions and 10 deletions

View File

@ -33,9 +33,7 @@ var Timeout time.Duration
var Commands []config.DockerCommand
// Not thread-safe, but for our case there is no cmdline parameters
// to update separate containers anyway
var Update = false
var UseCache = true
type Image struct {
Name string
@ -156,10 +154,6 @@ func (c Container) Name() string {
}
func (c Container) Exist() (yes bool) {
if Update {
return false
}
cmd := exec.Command(Runtime, "images", "-q", c.name)
c.Log.Debug().Msgf("run %v", cmd)
@ -212,7 +206,7 @@ func (c Container) Build(image string, envs, runs []string) (err error) {
}
}
if string(buf) == cf && c.Exist() {
if string(buf) == cf && c.Exist() && UseCache {
return
}
@ -239,7 +233,7 @@ func (c Container) Build(image string, envs, runs []string) (err error) {
func (c Container) build(imagePath string) (output string, err error) {
args := []string{"build"}
if Update {
if !UseCache {
args = append(args, "--pull", "--no-cache")
}
args = append(args, "-t", c.name, imagePath)

View File

@ -151,7 +151,7 @@ func (cmd *KernelCmd) GenKernel(km config.Target, pkg string) {
func (cmd *KernelCmd) Generate(g *Globals, km config.Target) (err error) {
if cmd.Update {
container.Update = true
container.UseCache = false
}
cmd.kcfg, err = config.ReadKernelConfig(g.Config.Kernels)