From 2df0d817822ba51fb91fc7333a6b0336fa71f826 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Thu, 17 Oct 2024 12:28:53 +0000 Subject: [PATCH] fix(container): prevent base image pull for non-registry containers --- container/container.go | 8 +++++++- distro/opensuse/opensuse.go | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/container/container.go b/container/container.go index de57cd7..dbf6a05 100644 --- a/container/container.go +++ b/container/container.go @@ -178,6 +178,9 @@ type Container struct { // Additional arguments Args []string + // Base of container is local-only + LocalBase bool + Log zerolog.Logger commandsOutput struct { @@ -428,7 +431,10 @@ func (c Container) build(imagePath string) (output string, err error) { args := []string{"build"} if !UseCache { - args = append(args, "--pull", "--no-cache") + if !c.LocalBase { + args = append(args, "--pull") + } + args = append(args, "--no-cache") } args = append(args, "-t", c.name, imagePath) diff --git a/distro/opensuse/opensuse.go b/distro/opensuse/opensuse.go index 3660278..914641e 100644 --- a/distro/opensuse/opensuse.go +++ b/distro/opensuse/opensuse.go @@ -57,6 +57,8 @@ func (suse OpenSUSE) Packages() (pkgs []string, err error) { if err != nil { return } + c.LocalBase = true + } else if strings.HasPrefix(suse.release, "13") { name = "opensuse:13" cnturl := cache.ContainerURL("openSUSE-13.2") @@ -64,6 +66,8 @@ func (suse OpenSUSE) Packages() (pkgs []string, err error) { if err != nil { return } + c.LocalBase = true + } else if strings.HasPrefix(suse.release, "42") { name = "opensuse/leap:42" } else if strings.HasPrefix(suse.release, "15") {