Skip to content

Commit

Permalink
add nerdctl/finch support
Browse files Browse the repository at this point in the history
Change-Id: I238214041e56d17dee8e15e58cd416300c506f44
  • Loading branch information
aojea committed Dec 13, 2024
1 parent 891607f commit 8107e71
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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"
}
}
}
}

Expand Down

0 comments on commit 8107e71

Please sign in to comment.