Skip to content

Commit 003646e

Browse files
committed
revert containerd support on macos
Signed-off-by: tianya <[email protected]>
1 parent a3fdee0 commit 003646e

File tree

2 files changed

+13
-29
lines changed

2 files changed

+13
-29
lines changed

Diff for: utils/utils.go

+9-19
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"os"
2525
"os/exec"
2626
"path/filepath"
27-
"runtime"
2827
"strings"
2928
"time"
3029

@@ -44,38 +43,33 @@ const (
4443
CONTAINERD ContainerRuntime = "containerd"
4544

4645
NERDCTL = "nerdctl"
47-
MACOS = runtime.GOOS == "darwin"
4846

4947
marinerImageVariantName = "mariner"
5048

5149
socketFormat = "%s/dapr-%s-%s.socket"
5250
)
5351

54-
var IsValidRuntimeOnMacos = func(containerRuntime string) bool {
55-
containerRuntime = strings.TrimSpace(containerRuntime)
56-
return containerRuntime == string(CONTAINERD) && !MACOS
57-
}
58-
5952
// IsValidContainerRuntime checks if the input is a valid container runtime.
6053
// Valid container runtimes are docker and podman and containerd.
6154
func IsValidContainerRuntime(containerRuntime string) bool {
6255
containerRuntime = strings.TrimSpace(containerRuntime)
63-
return containerRuntime == string(DOCKER) || containerRuntime == string(PODMAN) || IsValidRuntimeOnMacos(containerRuntime)
56+
return containerRuntime == string(DOCKER) || containerRuntime == string(PODMAN) || containerRuntime == string(CONTAINERD)
6457
}
6558

6659
// GetContainerRuntimeCmd returns a valid container runtime to be used by CLI operations.
6760
// If the input is a valid container runtime, it is returned client tool.
6861
// Otherwise the default container runtime, docker, is returned.
6962
func GetContainerRuntimeCmd(containerRuntime string) string {
70-
// containerd runtime use nerdctl tool.
71-
if IsValidRuntimeOnMacos(containerRuntime) {
63+
switch strings.TrimSpace(containerRuntime) {
64+
case string(CONTAINERD):
65+
// containerd runtime use nerdctl tool.
7266
return NERDCTL
67+
case string(PODMAN):
68+
return string(PODMAN)
69+
default:
70+
// Default to docker.
71+
return string(DOCKER)
7372
}
74-
if IsValidContainerRuntime(containerRuntime) {
75-
return strings.TrimSpace(containerRuntime)
76-
}
77-
// Default to docker.
78-
return string(DOCKER)
7973
}
8074

8175
// Contains returns true if vs contains x.
@@ -204,10 +198,6 @@ func IsPodmanInstalled() bool {
204198

205199
// IsContainerdInstalled checks whether nerdctl and containerd is installed/running.
206200
func IsContainerdInstalled() bool {
207-
if MACOS {
208-
print.FailureStatusEvent(os.Stderr, "containerd is not supported on macos")
209-
return false
210-
}
211201
if _, err := RunCmdAndWait("nerdctl", "info"); err != nil {
212202
print.FailureStatusEvent(os.Stderr, err.Error())
213203
return false

Diff for: utils/utils_test.go

+4-10
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ import (
2424
)
2525

2626
func TestContainerRuntimeUtils(t *testing.T) {
27-
containerCmd := func() string {
28-
if !MACOS {
29-
return "nerdctl"
30-
}
31-
return "docker"
32-
}()
3327
testcases := []struct {
3428
name string
3529
input string
@@ -39,14 +33,14 @@ func TestContainerRuntimeUtils(t *testing.T) {
3933
{
4034
name: "containerd runtime is valid, and nerdctl is returned",
4135
input: "containerd",
42-
expected: containerCmd,
43-
valid: !MACOS,
36+
expected: "nerdctl",
37+
valid: true,
4438
},
4539
{
4640
name: "containerd runtime with extra spaces is valid, and nerdctl is returned",
4741
input: " containerd ",
48-
expected: containerCmd,
49-
valid: !MACOS,
42+
expected: "nerdctl",
43+
valid: true,
5044
},
5145
{
5246
name: "podman runtime is valid, and is returned as is",

0 commit comments

Comments
 (0)