From be87861657d5663f012e8fc87d0cbdeabb08356d Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sun, 24 Jan 2021 13:17:11 +0100 Subject: [PATCH] img: pull image if not locally present while extracting --- pkg/compiler/backend/simpleimg.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/compiler/backend/simpleimg.go b/pkg/compiler/backend/simpleimg.go index caea55bb..34f3a566 100644 --- a/pkg/compiler/backend/simpleimg.go +++ b/pkg/compiler/backend/simpleimg.go @@ -147,10 +147,16 @@ func (*SimpleImg) ExportImage(opts compiler.CompilerBackendOptions) error { } // ExtractRootfs extracts the docker image content inside the destination -func (*SimpleImg) ExtractRootfs(opts compiler.CompilerBackendOptions, keepPerms bool) error { +func (s *SimpleImg) ExtractRootfs(opts compiler.CompilerBackendOptions, 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} Debug(":tea: Extracting image " + name)