mirror of
https://github.com/mudler/luet.git
synced 2025-09-16 15:19:24 +00:00
@@ -60,6 +60,7 @@ func (i ArtifactIndex) CleanPath() ArtifactIndex {
|
|||||||
Dependencies: art.Dependencies,
|
Dependencies: art.Dependencies,
|
||||||
CompressionType: art.CompressionType,
|
CompressionType: art.CompressionType,
|
||||||
Checksums: art.Checksums,
|
Checksums: art.Checksums,
|
||||||
|
Files: art.Files,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return newIndex
|
return newIndex
|
||||||
@@ -77,6 +78,7 @@ type PackageArtifact struct {
|
|||||||
Checksums Checksums `json:"checksums"`
|
Checksums Checksums `json:"checksums"`
|
||||||
SourceAssertion solver.PackagesAssertions `json:"-"`
|
SourceAssertion solver.PackagesAssertions `json:"-"`
|
||||||
CompressionType CompressionImplementation `json:"compressiontype"`
|
CompressionType CompressionImplementation `json:"compressiontype"`
|
||||||
|
Files []string `json:"files"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPackageArtifact(path string) Artifact {
|
func NewPackageArtifact(path string) Artifact {
|
||||||
@@ -116,9 +118,19 @@ func (a *PackageArtifact) SetCompressionType(t CompressionImplementation) {
|
|||||||
func (a *PackageArtifact) GetChecksums() Checksums {
|
func (a *PackageArtifact) GetChecksums() Checksums {
|
||||||
return a.Checksums
|
return a.Checksums
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *PackageArtifact) SetChecksums(c Checksums) {
|
func (a *PackageArtifact) SetChecksums(c Checksums) {
|
||||||
a.Checksums = c
|
a.Checksums = c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *PackageArtifact) SetFiles(f []string) {
|
||||||
|
a.Files = f
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *PackageArtifact) GetFiles() []string {
|
||||||
|
return a.Files
|
||||||
|
}
|
||||||
|
|
||||||
func (a *PackageArtifact) Hash() error {
|
func (a *PackageArtifact) Hash() error {
|
||||||
return a.Checksums.Generate(a)
|
return a.Checksums.Generate(a)
|
||||||
}
|
}
|
||||||
@@ -308,6 +320,7 @@ func (a *PackageArtifact) Unpack(dst string, keepPerms bool) error {
|
|||||||
return errors.New("Compression type must be supplied")
|
return errors.New("Compression type must be supplied")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FileList generates the list of file of a package from the local archive
|
||||||
func (a *PackageArtifact) FileList() ([]string, error) {
|
func (a *PackageArtifact) FileList() ([]string, error) {
|
||||||
var tr *tar.Reader
|
var tr *tar.Reader
|
||||||
switch a.CompressionType {
|
switch a.CompressionType {
|
||||||
|
@@ -420,9 +420,16 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
|
|||||||
artifact.SetCompileSpec(p)
|
artifact.SetCompileSpec(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filelist, err := artifact.FileList()
|
||||||
|
if err != nil {
|
||||||
|
return artifact, errors.Wrap(err, "Failed getting package list")
|
||||||
|
}
|
||||||
|
|
||||||
|
artifact.SetFiles(filelist)
|
||||||
|
|
||||||
err = artifact.WriteYaml(p.GetOutputPath())
|
err = artifact.WriteYaml(p.GetOutputPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return artifact, err
|
return artifact, errors.Wrap(err, "Failed while writing metadata file")
|
||||||
}
|
}
|
||||||
Info(pkgTag, " :white_check_mark: Done")
|
Info(pkgTag, " :white_check_mark: Done")
|
||||||
|
|
||||||
|
@@ -650,4 +650,43 @@ var _ = Describe("Compiler", func() {
|
|||||||
Expect(helpers.Exists(spec.Rel("var"))).ToNot(BeTrue())
|
Expect(helpers.Exists(spec.Rel("var"))).ToNot(BeTrue())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Context("File list", func() {
|
||||||
|
It("is generated after the compilation process and annotated in the metadata", func() {
|
||||||
|
generalRecipe := tree.NewCompilerRecipe(pkg.NewInMemoryDatabase(false))
|
||||||
|
|
||||||
|
err := generalRecipe.Load("../../tests/fixtures/packagelayers")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
Expect(len(generalRecipe.GetDatabase().GetPackages())).To(Equal(2))
|
||||||
|
|
||||||
|
compiler := NewLuetCompiler(sd.NewSimpleDockerBackend(), generalRecipe.GetDatabase(), NewDefaultCompilerOptions())
|
||||||
|
|
||||||
|
spec, err := compiler.FromPackage(&pkg.DefaultPackage{Name: "runtime", Category: "layer", Version: "0.1"})
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
compiler.SetCompressionType(GZip)
|
||||||
|
Expect(spec.GetPackage().GetPath()).ToNot(Equal(""))
|
||||||
|
|
||||||
|
tmpdir, err := ioutil.TempDir("", "tree")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
defer os.RemoveAll(tmpdir) // clean up
|
||||||
|
|
||||||
|
spec.SetOutputPath(tmpdir)
|
||||||
|
compiler.SetConcurrency(1)
|
||||||
|
|
||||||
|
artifacts, errs := compiler.CompileParallel(false, NewLuetCompilationspecs(spec))
|
||||||
|
Expect(errs).To(BeNil())
|
||||||
|
Expect(len(artifacts)).To(Equal(1))
|
||||||
|
Expect(len(artifacts[0].GetDependencies())).To(Equal(1))
|
||||||
|
Expect(artifacts[0].GetFiles()).To(ContainElement("bin/busybox"))
|
||||||
|
|
||||||
|
Expect(helpers.Exists(spec.Rel("runtime-layer-0.1.metadata.yaml"))).To(BeTrue())
|
||||||
|
|
||||||
|
art, err := LoadArtifactFromYaml(spec)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
files := art.GetFiles()
|
||||||
|
Expect(files).To(ContainElement("bin/busybox"))
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@@ -102,6 +102,9 @@ type Artifact interface {
|
|||||||
Hash() error
|
Hash() error
|
||||||
Verify() error
|
Verify() error
|
||||||
|
|
||||||
|
SetFiles(f []string)
|
||||||
|
GetFiles() []string
|
||||||
|
|
||||||
GetChecksums() Checksums
|
GetChecksums() Checksums
|
||||||
SetChecksums(c Checksums)
|
SetChecksums(c Checksums)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user