Move archive helpers to artifact

This allow in the future to swap and provide archive/compression methods without hijacking the code.

Refers to #33
This commit is contained in:
Ettore Di Giacinto
2019-12-28 16:32:32 +01:00
parent 8fffae31c7
commit 2fa9c754ae
4 changed files with 55 additions and 34 deletions

View File

@@ -339,13 +339,12 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
// strip from includes
cs.stripIncludesFromRootfs(p.GetIncludes(), rootfs)
}
err = helpers.Tar(rootfs, p.Rel(p.GetPackage().GetFingerPrint()+".package.tar"))
artifact = NewPackageArtifact(p.Rel(p.GetPackage().GetFingerPrint() + ".package.tar"))
err = artifact.Compress(rootfs)
if err != nil {
return nil, errors.Wrap(err, "Error met while creating package archive")
}
artifact = NewPackageArtifact(p.Rel(p.GetPackage().GetFingerPrint() + ".package.tar"))
artifact.SetCompileSpec(p)
} else {
Info(pkgTag, "Generating delta")
@@ -404,8 +403,10 @@ func (cs *LuetCompiler) packageFromImage(p CompilationSpec, tag string, keepPerm
if err != nil {
return nil, errors.Wrap(err, "Could not extract rootfs")
}
artifact := NewPackageArtifact(p.Rel(p.GetPackage().GetFingerPrint() + ".package.tar"))
artifact.SetCompileSpec(p)
err = helpers.Tar(rootfs, p.Rel(p.GetPackage().GetFingerPrint()+".package.tar"))
err = artifact.Compress(rootfs)
if err != nil {
return nil, errors.Wrap(err, "Error met while creating package archive")
}
@@ -422,8 +423,7 @@ func (cs *LuetCompiler) packageFromImage(p CompilationSpec, tag string, keepPerm
}
Info(pkgTag, " :white_check_mark: Done")
artifact := NewPackageArtifact(p.Rel(p.GetPackage().GetFingerPrint() + ".package.tar"))
artifact.SetCompileSpec(p)
err = artifact.WriteYaml(p.GetOutputPath())
if err != nil {
return artifact, err