Skip to content

Commit 85401df

Browse files
authored
Merge pull request #5061 from profnandaa/refactor-containerd-worker-5056
refactor: split containerd runtime options definions by OS
2 parents 01d7739 + 9e41728 commit 85401df

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

cmd/buildkitd/main_containerd_worker.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@ import (
1212
"strings"
1313
"time"
1414

15-
runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
1615
ctd "github.com/containerd/containerd"
1716
"github.com/containerd/containerd/defaults"
18-
runtimeoptions "github.com/containerd/containerd/pkg/runtimeoptions/v1"
1917
"github.com/containerd/containerd/pkg/userns"
20-
"github.com/containerd/containerd/plugin"
21-
runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
2218
"github.com/moby/buildkit/cmd/buildkitd/config"
2319
"github.com/moby/buildkit/util/bklog"
2420
"github.com/moby/buildkit/util/network/cniprovider"
@@ -34,9 +30,6 @@ import (
3430

3531
const (
3632
defaultContainerdNamespace = "buildkit"
37-
38-
// runtimeRunhcsV1 is the runtime type for runhcs.
39-
runtimeRunhcsV1 = "io.containerd.runhcs.v1"
4033
)
4134

4235
func init() {
@@ -373,15 +366,3 @@ func validContainerdSocket(cfg config.ContainerdConfig) bool {
373366
}
374367
return true
375368
}
376-
377-
// getRuntimeOptionsType gets empty runtime options by the runtime type name.
378-
func getRuntimeOptionsType(t string) interface{} {
379-
switch t {
380-
case plugin.RuntimeRuncV2:
381-
return &runcoptions.Options{}
382-
case runtimeRunhcsV1:
383-
return &runhcsoptions.Options{}
384-
default:
385-
return &runtimeoptions.Options{}
386-
}
387-
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//go:build !windows
2+
// +build !windows
3+
4+
package main
5+
6+
import (
7+
runtimeoptions "github.com/containerd/containerd/pkg/runtimeoptions/v1"
8+
"github.com/containerd/containerd/plugin"
9+
runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
10+
)
11+
12+
// getRuntimeOptionsType gets empty runtime options by the runtime type name.
13+
func getRuntimeOptionsType(t string) interface{} {
14+
if t == plugin.RuntimeRuncV2 {
15+
return &runcoptions.Options{}
16+
}
17+
return &runtimeoptions.Options{}
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package main
2+
3+
import (
4+
runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
5+
runtimeoptions "github.com/containerd/containerd/pkg/runtimeoptions/v1"
6+
)
7+
8+
const runtimeRunhcsV1 = "io.containerd.runhcs.v1"
9+
10+
// getRuntimeOptionsType gets empty runtime options by the runtime type name.
11+
func getRuntimeOptionsType(t string) interface{} {
12+
if t == runtimeRunhcsV1 {
13+
return &runhcsoptions.Options{}
14+
}
15+
return &runtimeoptions.Options{}
16+
}

0 commit comments

Comments
 (0)