Merge pull request #5936 from ukontainer/feature-darwin-runtime-shim

darwin: runtime support
This commit is contained in:
Phil Estes 2021-09-08 09:34:27 -04:00 committed by GitHub
commit 99987f2a5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 7 deletions

View File

@ -30,8 +30,7 @@ const (
// DefaultFIFODir is the default location used by client-side cio library // DefaultFIFODir is the default location used by client-side cio library
// to store FIFOs. // to store FIFOs.
DefaultFIFODir = "/var/run/containerd/fifo" DefaultFIFODir = "/var/run/containerd/fifo"
// DefaultRuntime is the default Darwin runtime. // DefaultRuntime would be a multiple of choices, thus empty
// NOTE: there is no runtime on Darwin as of now.
DefaultRuntime = "" DefaultRuntime = ""
// DefaultConfigDir is the default location for config files. // DefaultConfigDir is the default location for config files.
DefaultConfigDir = "/etc/containerd" DefaultConfigDir = "/etc/containerd"

View File

@ -0,0 +1,44 @@
// +build darwin
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package platforms
import (
"runtime"
specs "github.com/opencontainers/image-spec/specs-go/v1"
)
// DefaultSpec returns the current platform's default platform specification.
func DefaultSpec() specs.Platform {
return specs.Platform{
OS: runtime.GOOS,
Architecture: runtime.GOARCH,
// The Variant field will be empty if arch != ARM.
Variant: cpuVariant(),
}
}
// Default returns the default matcher for the platform.
func Default() MatchComparer {
return Ordered(DefaultSpec(), specs.Platform{
// darwin runtime also supports Linux binary via runu/LKL
OS: "linux",
Architecture: runtime.GOARCH,
})
}

View File

@ -1,5 +1,5 @@
//go:build !windows //go:build !windows && !darwin
// +build !windows // +build !windows,!darwin
/* /*
Copyright The containerd Authors. Copyright The containerd Authors.

View File

@ -30,6 +30,7 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/pkg/dialer" "github.com/containerd/containerd/pkg/dialer"
"github.com/containerd/containerd/sys" "github.com/containerd/containerd/sys"
@ -63,7 +64,7 @@ func AdjustOOMScore(pid int) error {
return nil return nil
} }
const socketRoot = "/run/containerd" const socketRoot = defaults.DefaultStateDir
// SocketAddress returns a socket address // SocketAddress returns a socket address
func SocketAddress(ctx context.Context, socketPath, id string) (string, error) { func SocketAddress(ctx context.Context, socketPath, id string) (string, error) {

View File

@ -0,0 +1,35 @@
// +build darwin
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package tasks
import (
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/runtime"
)
var tasksServiceRequires = []plugin.Type{
plugin.RuntimePluginV2,
plugin.MetadataPlugin,
plugin.TaskMonitorPlugin,
}
// loadV1Runtimes on darwin returns an empty map. There are no v1 runtimes
func loadV1Runtimes(ic *plugin.InitContext) (map[string]runtime.PlatformRuntime, error) {
return make(map[string]runtime.PlatformRuntime), nil
}

View File

@ -1,5 +1,5 @@
//go:build !windows && !freebsd //go:build !windows && !freebsd && !darwin
// +build !windows,!freebsd // +build !windows,!freebsd,!darwin
/* /*
Copyright The containerd Authors. Copyright The containerd Authors.