refactor: cache control for the container module
This commit is contained in:
parent
004d4223f9
commit
ca57ea2dac
@ -33,9 +33,7 @@ var Timeout time.Duration
|
|||||||
|
|
||||||
var Commands []config.DockerCommand
|
var Commands []config.DockerCommand
|
||||||
|
|
||||||
// Not thread-safe, but for our case there is no cmdline parameters
|
var UseCache = true
|
||||||
// to update separate containers anyway
|
|
||||||
var Update = false
|
|
||||||
|
|
||||||
type Image struct {
|
type Image struct {
|
||||||
Name string
|
Name string
|
||||||
@ -156,10 +154,6 @@ func (c Container) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c Container) Exist() (yes bool) {
|
func (c Container) Exist() (yes bool) {
|
||||||
if Update {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command(Runtime, "images", "-q", c.name)
|
cmd := exec.Command(Runtime, "images", "-q", c.name)
|
||||||
|
|
||||||
c.Log.Debug().Msgf("run %v", cmd)
|
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
|
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) {
|
func (c Container) build(imagePath string) (output string, err error) {
|
||||||
args := []string{"build"}
|
args := []string{"build"}
|
||||||
if Update {
|
if !UseCache {
|
||||||
args = append(args, "--pull", "--no-cache")
|
args = append(args, "--pull", "--no-cache")
|
||||||
}
|
}
|
||||||
args = append(args, "-t", c.name, imagePath)
|
args = append(args, "-t", c.name, imagePath)
|
||||||
|
@ -151,7 +151,7 @@ func (cmd *KernelCmd) GenKernel(km config.Target, pkg string) {
|
|||||||
|
|
||||||
func (cmd *KernelCmd) Generate(g *Globals, km config.Target) (err error) {
|
func (cmd *KernelCmd) Generate(g *Globals, km config.Target) (err error) {
|
||||||
if cmd.Update {
|
if cmd.Update {
|
||||||
container.Update = true
|
container.UseCache = false
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.kcfg, err = config.ReadKernelConfig(g.Config.Kernels)
|
cmd.kcfg, err = config.ReadKernelConfig(g.Config.Kernels)
|
||||||
|
Loading…
Reference in New Issue
Block a user