Use API also when pulling from helpers used in client

This commit is contained in:
Ettore Di Giacinto
2021-10-24 00:57:50 +02:00
parent ad489c2157
commit ebbb3aad27
17 changed files with 113 additions and 233 deletions

View File

@@ -16,7 +16,6 @@
package backend
import (
"os"
"os/exec"
"strings"
@@ -178,33 +177,6 @@ func (s *SimpleImg) ExportImage(opts Options) error {
return nil
}
// ExtractRootfs extracts the docker image content inside the destination
func (s *SimpleImg) ExtractRootfs(opts Options, keepPerms bool) error {
name := opts.ImageName
path := opts.Destination
if !s.ImageExists(name) {
if err := s.DownloadImage(opts); err != nil {
return errors.Wrap(err, "failed pulling image "+name+" during extraction")
}
}
os.RemoveAll(path)
buildarg := []string{"unpack", "-o", path, name}
s.ctx.Debug(":tea: Extracting image " + name)
s.ctx.Spinner()
defer s.ctx.SpinnerStop()
out, err := exec.Command("img", buildarg...).CombinedOutput()
if err != nil {
return errors.Wrap(err, "Failed extracting image: "+string(out))
}
s.ctx.Debug(":tea: Image " + name + " extracted")
return nil
}
func (s *SimpleImg) Push(opts Options) error {
name := opts.ImageName
bus.Manager.Publish(bus.EventImagePrePush, opts)