Compare commits

...

6 Commits

Author SHA1 Message Date
Ettore Di Giacinto
e705c471eb Tag 0.20.2 2021-10-26 00:30:12 +02:00
Itxaka
7cd455fff4 Set proper error message on plugin failure
Currently we are setting the error message in a no-space full sentence
which is pretty ugly:

| FATA[0000] Pluginluet-cosignat/usr/local/bin/luet-cosignErrorerror while executing plugin: exit status 1

Signed-off-by: Itxaka <igarcia@suse.com>
2021-10-26 00:28:30 +02:00
Ettore Di Giacinto
144c409908 Disable buffer on docker remote
This causes to load otherwise the full tarball into memory
2021-10-25 23:57:09 +02:00
Ettore Di Giacinto
f6bb7a9405 Make sure to pull images before generating artifacts
Fixes #262
2021-10-25 23:56:38 +02:00
Ettore Di Giacinto
9d3af649f1 Tag 0.20.1 2021-10-24 22:31:20 +02:00
Ettore Di Giacinto
1b1ab6225c Use table lookup for checking addition files 2021-10-24 21:55:42 +02:00
5 changed files with 58 additions and 49 deletions

View File

@@ -30,7 +30,7 @@ var cfgFile string
var Verbose bool
const (
LuetCLIVersion = "0.20.0"
LuetCLIVersion = "0.20.2"
LuetEnvPrefix = "LUET"
)

View File

@@ -1,6 +1,7 @@
package bus
import (
"fmt"
"github.com/mudler/go-pluggable"
"github.com/mudler/luet/pkg/api/core/types"
)
@@ -88,7 +89,8 @@ func (b *Bus) Initialize(ctx *types.Context, plugin ...string) {
for _, e := range b.Manager.Events {
b.Manager.Response(e, func(p *pluggable.Plugin, r *pluggable.EventResponse) {
if r.Errored() {
ctx.Fatal("Plugin", p.Name, "at", p.Executable, "Error", r.Error)
err := fmt.Sprintf("Plugin %s at %s had an error: %s", p.Name, p.Executable, r.Error)
ctx.Fatal(err)
}
ctx.Debug(
"plugin_event",

View File

@@ -46,18 +46,42 @@ func ExtractDeltaFiles(
includeRegexp := compileRegexes(includes)
excludeRegexp := compileRegexes(excludes)
additions := map[string]interface{}{}
for _, a := range d.Additions {
additions[a.Name] = nil
}
return func(h *tar.Header) (bool, error) {
fileName := filepath.Join(string(os.PathSeparator), h.Name)
ctx.Debug("Includes", includes)
ctx.Debug("Excludes", excludes)
ctx.Debug("Additions", d.Additions)
_, exists := additions[h.Name]
if !exists {
return false, nil
}
switch {
case len(includes) == 0 && len(excludes) != 0:
for _, a := range d.Additions {
if h.Name == a.Name {
for _, i := range excludeRegexp {
if i.MatchString(filepath.Join(string(os.PathSeparator), a.Name)) &&
fileName == filepath.Join(string(os.PathSeparator), a.Name) {
for _, i := range excludeRegexp {
if i.MatchString(filepath.Join(string(os.PathSeparator), h.Name)) &&
fileName == filepath.Join(string(os.PathSeparator), h.Name) {
return false, nil
}
}
ctx.Debug("Adding name", fileName)
return true, nil
case len(includes) > 0 && len(excludes) == 0:
for _, i := range includeRegexp {
if i.MatchString(filepath.Join(string(os.PathSeparator), h.Name)) && fileName == filepath.Join(string(os.PathSeparator), h.Name) {
ctx.Debug("Adding name", fileName)
return true, nil
}
}
return false, nil
case len(includes) != 0 && len(excludes) != 0:
for _, i := range includeRegexp {
if i.MatchString(filepath.Join(string(os.PathSeparator), h.Name)) && fileName == filepath.Join(string(os.PathSeparator), h.Name) {
for _, e := range excludeRegexp {
if e.MatchString(fileName) {
return false, nil
}
}
@@ -66,43 +90,11 @@ func ExtractDeltaFiles(
return true, nil
}
}
return false, nil
case len(includes) > 0 && len(excludes) == 0:
for _, a := range d.Additions {
for _, i := range includeRegexp {
if i.MatchString(filepath.Join(string(os.PathSeparator), a.Name)) && fileName == filepath.Join(string(os.PathSeparator), a.Name) {
ctx.Debug("Adding name", fileName)
return true, nil
}
}
}
return false, nil
case len(includes) != 0 && len(excludes) != 0:
for _, a := range d.Additions {
for _, i := range includeRegexp {
if i.MatchString(filepath.Join(string(os.PathSeparator), a.Name)) && fileName == filepath.Join(string(os.PathSeparator), a.Name) {
for _, e := range excludeRegexp {
if e.MatchString(fileName) {
return false, nil
}
}
ctx.Debug("Adding name", fileName)
return true, nil
}
}
}
return false, nil
default:
for _, a := range d.Additions {
if fileName == filepath.Join(string(os.PathSeparator), a.Name) {
ctx.Debug("Adding name", fileName)
return true, nil
}
}
return false, nil
ctx.Debug("Adding name", fileName)
return true, nil
}
}

View File

@@ -144,7 +144,7 @@ func (s *SimpleDocker) ImageReference(a string) (v1.Image, error) {
return nil, err
}
img, err := daemon.Image(ref)
img, err := daemon.Image(ref, daemon.WithUnbufferedOpener())
if err != nil {
return nil, err
}

View File

@@ -227,6 +227,13 @@ func (cs *LuetCompiler) stripFromRootfs(includes []string, rootfs string, includ
}
func (cs *LuetCompiler) unpackFs(concurrency int, keepPermissions bool, p *compilerspec.LuetCompilationSpec, runnerOpts backend.Options) (*artifact.PackageArtifact, error) {
if !cs.Backend.ImageExists(runnerOpts.ImageName) {
if err := cs.Backend.DownloadImage(runnerOpts); err != nil {
return nil, errors.Wrap(err, "failed pulling image "+runnerOpts.ImageName+" during extraction")
}
}
img, err := cs.Backend.ImageReference(runnerOpts.ImageName)
if err != nil {
return nil, err
@@ -287,10 +294,18 @@ func (cs *LuetCompiler) unpackDelta(concurrency int, keepPermissions bool, p *co
defer os.RemoveAll(rootfs) // clean up
pkgTag := ":package: " + p.GetPackage().HumanReadableString()
if cs.Options.PullFirst && !cs.Backend.ImageExists(builderOpts.ImageName) && cs.Backend.ImageAvailable(builderOpts.ImageName) {
err := cs.Backend.DownloadImage(builderOpts)
if err != nil {
return nil, errors.Wrap(err, "Could not pull image")
if cs.Options.PullFirst {
if !cs.Backend.ImageExists(builderOpts.ImageName) {
err := cs.Backend.DownloadImage(builderOpts)
if err != nil {
return nil, errors.Wrap(err, "Could not pull image")
}
}
if !cs.Backend.ImageExists(runnerOpts.ImageName) {
err := cs.Backend.DownloadImage(runnerOpts)
if err != nil {
return nil, errors.Wrap(err, "Could not pull image")
}
}
}