Skip to content

Commit

Permalink
Merge pull request #5061 from profnandaa/refactor-containerd-worker-5056
Browse files Browse the repository at this point in the history
refactor: split containerd runtime options definions by OS
  • Loading branch information
tonistiigi authored Jun 19, 2024
2 parents 01d7739 + 9e41728 commit 85401df
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
19 changes: 0 additions & 19 deletions cmd/buildkitd/main_containerd_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ import (
"strings"
"time"

runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
ctd "github.com/containerd/containerd"
"github.com/containerd/containerd/defaults"
runtimeoptions "github.com/containerd/containerd/pkg/runtimeoptions/v1"
"github.com/containerd/containerd/pkg/userns"
"github.com/containerd/containerd/plugin"
runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
"github.com/moby/buildkit/cmd/buildkitd/config"
"github.com/moby/buildkit/util/bklog"
"github.com/moby/buildkit/util/network/cniprovider"
Expand All @@ -34,9 +30,6 @@ import (

const (
defaultContainerdNamespace = "buildkit"

// runtimeRunhcsV1 is the runtime type for runhcs.
runtimeRunhcsV1 = "io.containerd.runhcs.v1"
)

func init() {
Expand Down Expand Up @@ -373,15 +366,3 @@ func validContainerdSocket(cfg config.ContainerdConfig) bool {
}
return true
}

// getRuntimeOptionsType gets empty runtime options by the runtime type name.
func getRuntimeOptionsType(t string) interface{} {
switch t {
case plugin.RuntimeRuncV2:
return &runcoptions.Options{}
case runtimeRunhcsV1:
return &runhcsoptions.Options{}
default:
return &runtimeoptions.Options{}
}
}
18 changes: 18 additions & 0 deletions cmd/buildkitd/main_containerd_worker_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//go:build !windows
// +build !windows

package main

import (
runtimeoptions "github.com/containerd/containerd/pkg/runtimeoptions/v1"
"github.com/containerd/containerd/plugin"
runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
)

// getRuntimeOptionsType gets empty runtime options by the runtime type name.
func getRuntimeOptionsType(t string) interface{} {
if t == plugin.RuntimeRuncV2 {
return &runcoptions.Options{}
}
return &runtimeoptions.Options{}
}
16 changes: 16 additions & 0 deletions cmd/buildkitd/main_containerd_worker_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
runtimeoptions "github.com/containerd/containerd/pkg/runtimeoptions/v1"
)

const runtimeRunhcsV1 = "io.containerd.runhcs.v1"

// getRuntimeOptionsType gets empty runtime options by the runtime type name.
func getRuntimeOptionsType(t string) interface{} {
if t == runtimeRunhcsV1 {
return &runhcsoptions.Options{}
}
return &runtimeoptions.Options{}
}

0 comments on commit 85401df

Please sign in to comment.