From 8107e7110ce83a29717877738d991fb8a84c9bbf Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Fri, 13 Dec 2024 06:54:17 +0000 Subject: [PATCH] add nerdctl/finch support Change-Id: I238214041e56d17dee8e15e58cd416300c506f44 --- pkg/container/container.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pkg/container/container.go b/pkg/container/container.go index 68412fd2..e2464aaf 100644 --- a/pkg/container/container.go +++ b/pkg/container/container.go @@ -32,7 +32,21 @@ func podmanIsAvailable() bool { return false } return strings.HasPrefix(lines[0], "podman version") +} +func nerdctlIsAvailable() bool { + cmd := kindexec.Command("nerdctl", "-v") + lines, err := kindexec.OutputLines(cmd) + if err != nil || len(lines) != 1 { + // check finch + cmd = kindexec.Command("finch", "-v") + lines, err = kindexec.OutputLines(cmd) + if err != nil || len(lines) != 1 { + return false + } + return strings.HasPrefix(lines[0], "finch version") + } + return strings.HasPrefix(lines[0], "nerdctl version") } func init() { @@ -41,6 +55,15 @@ func init() { } if podmanIsAvailable() { containerRuntime = "podman" + return + } + if nerdctlIsAvailable() { + containerRuntime = "nerdctl" + if _, err := exec.LookPath("nerdctl"); err != nil { + if _, err := exec.LookPath("finch"); err == nil { + containerRuntime = "finch" + } + } } }