Skip building if artifact already exists

This commit is contained in:
Ettore Di Giacinto 2020-01-05 15:30:16 +01:00
parent bcc6ce19ea
commit 1d1efad18b
No known key found for this signature in database
GPG Key ID: 1ADA699B145A2D1C
2 changed files with 21 additions and 0 deletions

View File

@ -92,6 +92,17 @@ func NewPackageArtifactFromYaml(data []byte) (Artifact, error) {
return p, err
}
func LoadArtifactFromYaml(spec CompilationSpec) (Artifact, error) {
metaFile := spec.GetPackage().GetFingerPrint() + ".metadata.yaml"
dat, err := ioutil.ReadFile(spec.Rel(metaFile))
if err != nil {
return nil, errors.Wrap(err, "Error reading file "+metaFile)
}
return NewPackageArtifactFromYaml(dat)
}
func (a *PackageArtifact) SetCompressionType(t CompressionImplementation) {
a.CompressionType = t
}

View File

@ -227,6 +227,11 @@ func (cs *LuetCompiler) stripIncludesFromRootfs(includes []string, rootfs string
}
func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage string, concurrency int, keepPermissions, keepImg bool, p CompilationSpec) (Artifact, error) {
if !cs.Clean {
if art, err := LoadArtifactFromYaml(p); err == nil {
return art, err
}
}
pkgTag := ":package: " + p.GetPackage().GetName()
p.SetSeedImage(image) // In this case, we ignore the build deps as we suppose that the image has them - otherwise we recompose the tree with a solver,
@ -382,6 +387,11 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
}
func (cs *LuetCompiler) packageFromImage(p CompilationSpec, tag string, keepPermissions, keepImg bool, concurrency int) (Artifact, error) {
if !cs.Clean {
if art, err := LoadArtifactFromYaml(p); err == nil {
return art, err
}
}
pkgTag := ":package: " + p.GetPackage().GetName()
Info(pkgTag, " 🍩 Build starts 🔨 🔨 🔨 ")