From 6ff3e09d201c82839be50f176895656d2bbcffec Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 3 Jun 2024 15:13:30 +0200 Subject: [PATCH] migrate platforms package to github.com/containerd/platforms This updates the platforms package to be an alias for the new platforms module. This helps transitioning consumers to the new module, and makes sure that containerd v2 and v1 use the same definitions. Signed-off-by: Sebastiaan van Stijn --- client.go | 2 +- client_opts.go | 2 +- cmd/ctr/commands/content/fetch.go | 2 +- cmd/ctr/commands/images/convert.go | 2 +- cmd/ctr/commands/images/export.go | 2 +- cmd/ctr/commands/images/images.go | 2 +- cmd/ctr/commands/images/import.go | 2 +- cmd/ctr/commands/images/mount.go | 2 +- cmd/ctr/commands/images/pull.go | 2 +- cmd/ctr/commands/images/push.go | 2 +- cmd/ctr/commands/oci/oci.go | 2 +- cmd/ctr/commands/plugins/plugins.go | 2 +- cmd/ctr/commands/run/run_unix.go | 2 +- container_checkpoint_opts.go | 2 +- contrib/fuzz/fuzz_images.go | 2 +- diff/walking/plugin/plugin.go | 2 +- diff/windows/windows.go | 2 +- go.mod | 1 + go.sum | 2 + image.go | 2 +- images/archive/exporter.go | 2 +- images/archive/importer.go | 2 +- images/converter/converter.go | 2 +- images/converter/default.go | 2 +- images/handlers.go | 2 +- images/image.go | 2 +- import.go | 2 +- .../build_local_containerd_helper_test.go | 2 +- integration/client/client_test.go | 2 +- integration/client/client_unix_test.go | 2 +- integration/client/container_test.go | 2 +- integration/client/convert_test.go | 2 +- integration/client/export_test.go | 2 +- integration/client/go.mod | 1 + integration/client/go.sum | 41 ++ integration/client/image_test.go | 2 +- integration/client/import_test.go | 2 +- metrics/cgroups/cgroups.go | 2 +- oci/spec.go | 2 +- oci/spec_opts.go | 2 +- pkg/cri/cri.go | 2 +- pkg/cri/sbserver/container_create.go | 2 +- .../sbserver/container_create_linux_test.go | 2 +- pkg/cri/sbserver/container_create_test.go | 2 +- pkg/cri/sbserver/podsandbox/controller.go | 2 +- pkg/cri/sbserver/restart.go | 2 +- pkg/cri/server/restart.go | 2 +- pkg/transfer/archive/exporter.go | 2 +- pkg/transfer/image/imagestore.go | 2 +- pkg/transfer/local/pull_test.go | 2 +- pkg/transfer/local/push.go | 2 +- pkg/unpack/unpacker.go | 2 +- platforms/compare_test.go | 415 ------------------ platforms/cpuinfo_linux_test.go | 141 ------ platforms/defaults_windows_test.go | 374 ---------------- platforms/platforms_deprecated.go | 138 ++++++ ..._test.go => platforms_deprecated_other.go} | 26 +- platforms/platforms_deprecated_windows.go | 48 ++ platforms/platforms_test.go | 376 ---------------- plugins/transfer/plugin.go | 2 +- pull.go | 2 +- remotes/handlers.go | 2 +- runtime/v1/linux/runtime.go | 2 +- runtime/v2/manager.go | 2 +- runtime/v2/manager_unix.go | 2 +- runtime/v2/manager_windows.go | 2 +- services/server/server.go | 2 +- snapshots/blockfile/plugin/plugin.go | 2 +- snapshots/btrfs/plugin/plugin.go | 2 +- snapshots/devmapper/plugin/plugin.go | 2 +- snapshots/native/plugin/plugin.go | 2 +- snapshots/overlay/plugin/plugin.go | 2 +- snapshots/windows/windows.go | 2 +- .../containerd/platforms/.gitattributes | 1 + .../containerd/platforms/.golangci.yml | 30 ++ .../github.com/containerd/platforms/LICENSE | 191 ++++++++ .../github.com/containerd/platforms/README.md | 32 ++ .../containerd/platforms}/compare.go | 0 .../containerd/platforms}/cpuinfo.go | 0 .../containerd/platforms}/cpuinfo_linux.go | 13 +- .../containerd/platforms}/cpuinfo_other.go | 6 +- .../containerd/platforms}/database.go | 0 .../containerd/platforms}/defaults.go | 6 +- .../containerd/platforms}/defaults_darwin.go | 0 .../containerd/platforms}/defaults_freebsd.go | 0 .../containerd/platforms}/defaults_unix.go | 0 .../containerd/platforms}/defaults_windows.go | 0 .../github.com/containerd/platforms/errors.go | 34 +- .../containerd/platforms}/platforms.go | 96 ++-- .../containerd/platforms}/platforms_other.go | 4 - .../platforms}/platforms_windows.go | 8 - vendor/modules.txt | 3 + 92 files changed, 639 insertions(+), 1472 deletions(-) delete mode 100644 platforms/compare_test.go delete mode 100644 platforms/cpuinfo_linux_test.go delete mode 100644 platforms/defaults_windows_test.go create mode 100644 platforms/platforms_deprecated.go rename platforms/{platforms_windows_test.go => platforms_deprecated_other.go} (55%) create mode 100644 platforms/platforms_deprecated_windows.go delete mode 100644 platforms/platforms_test.go create mode 100644 vendor/github.com/containerd/platforms/.gitattributes create mode 100644 vendor/github.com/containerd/platforms/.golangci.yml create mode 100644 vendor/github.com/containerd/platforms/LICENSE create mode 100644 vendor/github.com/containerd/platforms/README.md rename {platforms => vendor/github.com/containerd/platforms}/compare.go (100%) rename {platforms => vendor/github.com/containerd/platforms}/cpuinfo.go (100%) rename {platforms => vendor/github.com/containerd/platforms}/cpuinfo_linux.go (94%) rename {platforms => vendor/github.com/containerd/platforms}/cpuinfo_other.go (95%) rename {platforms => vendor/github.com/containerd/platforms}/database.go (100%) rename {platforms => vendor/github.com/containerd/platforms}/defaults.go (81%) rename {platforms => vendor/github.com/containerd/platforms}/defaults_darwin.go (100%) rename {platforms => vendor/github.com/containerd/platforms}/defaults_freebsd.go (100%) rename {platforms => vendor/github.com/containerd/platforms}/defaults_unix.go (100%) rename {platforms => vendor/github.com/containerd/platforms}/defaults_windows.go (100%) rename platforms/defaults_unix_test.go => vendor/github.com/containerd/platforms/errors.go (53%) rename {platforms => vendor/github.com/containerd/platforms}/platforms.go (74%) rename {platforms => vendor/github.com/containerd/platforms}/platforms_other.go (94%) rename {platforms => vendor/github.com/containerd/platforms}/platforms_windows.go (85%) diff --git a/client.go b/client.go index 94193041e4..13dc4da8c9 100644 --- a/client.go +++ b/client.go @@ -50,7 +50,6 @@ import ( leasesproxy "github.com/containerd/containerd/leases/proxy" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/dialer" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" ptypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/remotes" @@ -61,6 +60,7 @@ import ( "github.com/containerd/containerd/snapshots" snproxy "github.com/containerd/containerd/snapshots/proxy" "github.com/containerd/errdefs" + "github.com/containerd/platforms" "github.com/containerd/typeurl/v2" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/opencontainers/runtime-spec/specs-go" diff --git a/client_opts.go b/client_opts.go index 4e0a78a8a3..841e1b566a 100644 --- a/client_opts.go +++ b/client_opts.go @@ -20,9 +20,9 @@ import ( "time" "github.com/containerd/containerd/images" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/snapshots" + "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "google.golang.org/grpc" diff --git a/cmd/ctr/commands/content/fetch.go b/cmd/ctr/commands/content/fetch.go index 157ce954d4..7c7aff7c79 100644 --- a/cmd/ctr/commands/content/fetch.go +++ b/cmd/ctr/commands/content/fetch.go @@ -31,10 +31,10 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/progress" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/remotes" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/urfave/cli" diff --git a/cmd/ctr/commands/images/convert.go b/cmd/ctr/commands/images/convert.go index 7e81c23dff..96e9405cf2 100644 --- a/cmd/ctr/commands/images/convert.go +++ b/cmd/ctr/commands/images/convert.go @@ -23,7 +23,7 @@ import ( "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/images/converter" "github.com/containerd/containerd/images/converter/uncompress" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/urfave/cli" ) diff --git a/cmd/ctr/commands/images/export.go b/cmd/ctr/commands/images/export.go index 4cd864ef43..1225dc1764 100644 --- a/cmd/ctr/commands/images/export.go +++ b/cmd/ctr/commands/images/export.go @@ -30,7 +30,7 @@ import ( "github.com/containerd/containerd/pkg/transfer" tarchive "github.com/containerd/containerd/pkg/transfer/archive" "github.com/containerd/containerd/pkg/transfer/image" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ) var exportCommand = cli.Command{ diff --git a/cmd/ctr/commands/images/images.go b/cmd/ctr/commands/images/images.go index 010fdec56f..94136f0bd0 100644 --- a/cmd/ctr/commands/images/images.go +++ b/cmd/ctr/commands/images/images.go @@ -27,9 +27,9 @@ import ( "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/progress" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" "github.com/urfave/cli" ) diff --git a/cmd/ctr/commands/images/import.go b/cmd/ctr/commands/images/import.go index a7ed7059a4..992e9684e6 100644 --- a/cmd/ctr/commands/images/import.go +++ b/cmd/ctr/commands/images/import.go @@ -31,8 +31,8 @@ import ( "github.com/containerd/containerd/pkg/transfer" tarchive "github.com/containerd/containerd/pkg/transfer/archive" "github.com/containerd/containerd/pkg/transfer/image" - "github.com/containerd/containerd/platforms" "github.com/containerd/log" + "github.com/containerd/platforms" ) var importCommand = cli.Command{ diff --git a/cmd/ctr/commands/images/mount.go b/cmd/ctr/commands/images/mount.go index a45cff2e2b..85482e6714 100644 --- a/cmd/ctr/commands/images/mount.go +++ b/cmd/ctr/commands/images/mount.go @@ -24,8 +24,8 @@ import ( "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" + "github.com/containerd/platforms" "github.com/opencontainers/image-spec/identity" "github.com/urfave/cli" ) diff --git a/cmd/ctr/commands/images/pull.go b/cmd/ctr/commands/images/pull.go index fc6d364d80..61295d81dd 100644 --- a/cmd/ctr/commands/images/pull.go +++ b/cmd/ctr/commands/images/pull.go @@ -32,8 +32,8 @@ import ( "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/transfer/image" "github.com/containerd/containerd/pkg/transfer/registry" - "github.com/containerd/containerd/platforms" "github.com/containerd/log" + "github.com/containerd/platforms" "github.com/opencontainers/image-spec/identity" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/urfave/cli" diff --git a/cmd/ctr/commands/images/push.go b/cmd/ctr/commands/images/push.go index 464a33527b..e71164b64a 100644 --- a/cmd/ctr/commands/images/push.go +++ b/cmd/ctr/commands/images/push.go @@ -34,10 +34,10 @@ import ( "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/transfer/image" "github.com/containerd/containerd/pkg/transfer/registry" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" "github.com/containerd/log" + "github.com/containerd/platforms" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/urfave/cli" diff --git a/cmd/ctr/commands/oci/oci.go b/cmd/ctr/commands/oci/oci.go index a8eb76a87c..7dab00da09 100644 --- a/cmd/ctr/commands/oci/oci.go +++ b/cmd/ctr/commands/oci/oci.go @@ -24,7 +24,7 @@ import ( "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/containers" "github.com/containerd/containerd/oci" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ) // Command is the parent for all OCI related tools under 'oci' diff --git a/cmd/ctr/commands/plugins/plugins.go b/cmd/ctr/commands/plugins/plugins.go index 4cdd0b1e65..f990341c63 100644 --- a/cmd/ctr/commands/plugins/plugins.go +++ b/cmd/ctr/commands/plugins/plugins.go @@ -25,8 +25,8 @@ import ( "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/containerd/platforms" pluginutils "github.com/containerd/containerd/plugin" + "github.com/containerd/platforms" v1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/urfave/cli" "google.golang.org/grpc/codes" diff --git a/cmd/ctr/commands/run/run_unix.go b/cmd/ctr/commands/run/run_unix.go index 5a430e05a9..b3e5d0e2db 100644 --- a/cmd/ctr/commands/run/run_unix.go +++ b/cmd/ctr/commands/run/run_unix.go @@ -35,9 +35,9 @@ import ( "github.com/containerd/containerd/contrib/seccomp" "github.com/containerd/containerd/oci" runtimeoptions "github.com/containerd/containerd/pkg/runtimeoptions/v1" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/containerd/containerd/snapshots" + "github.com/containerd/platforms" "github.com/intel/goresctrl/pkg/blockio" "github.com/opencontainers/runtime-spec/specs-go" "github.com/urfave/cli" diff --git a/container_checkpoint_opts.go b/container_checkpoint_opts.go index 64f23823d2..5aa683a163 100644 --- a/container_checkpoint_opts.go +++ b/container_checkpoint_opts.go @@ -27,11 +27,11 @@ import ( "github.com/containerd/containerd/containers" "github.com/containerd/containerd/diff" "github.com/containerd/containerd/images" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/protobuf/proto" "github.com/containerd/containerd/rootfs" "github.com/containerd/containerd/runtime/v2/runc/options" + "github.com/containerd/platforms" "github.com/opencontainers/go-digest" imagespec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/contrib/fuzz/fuzz_images.go b/contrib/fuzz/fuzz_images.go index bf5a02a129..29ebdf6537 100644 --- a/contrib/fuzz/fuzz_images.go +++ b/contrib/fuzz/fuzz_images.go @@ -22,7 +22,7 @@ import ( fuzz "github.com/AdaLogics/go-fuzz-headers" "github.com/containerd/containerd/content/local" "github.com/containerd/containerd/images" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/diff/walking/plugin/plugin.go b/diff/walking/plugin/plugin.go index a2dcc1094b..90bc8d7145 100644 --- a/diff/walking/plugin/plugin.go +++ b/diff/walking/plugin/plugin.go @@ -21,8 +21,8 @@ import ( "github.com/containerd/containerd/diff/apply" "github.com/containerd/containerd/diff/walking" "github.com/containerd/containerd/metadata" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" + "github.com/containerd/platforms" ) func init() { diff --git a/diff/windows/windows.go b/diff/windows/windows.go index 0e3555318b..8a327121c6 100644 --- a/diff/windows/windows.go +++ b/diff/windows/windows.go @@ -36,10 +36,10 @@ import ( "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/pkg/epoch" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/go.mod b/go.mod index 9f0663a770..bbe1ba59a5 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( github.com/containerd/imgcrypt v1.1.8 github.com/containerd/log v0.1.0 github.com/containerd/nri v0.6.1 + github.com/containerd/platforms v0.2.0 github.com/containerd/ttrpc v1.2.4 github.com/containerd/typeurl/v2 v2.1.1 github.com/containerd/zfs v1.1.0 diff --git a/go.sum b/go.sum index 34799b126a..7e11cec482 100644 --- a/go.sum +++ b/go.sum @@ -194,6 +194,8 @@ github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3 github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164/go.mod h1:+2wGSDGFYfE5+So4M5syatU0N0f0LbWpuqyMi4/BE8c= github.com/containerd/nri v0.6.1 h1:xSQ6elnQ4Ynidm9u49ARK9wRKHs80HCUI+bkXOxV4mA= github.com/containerd/nri v0.6.1/go.mod h1:7+sX3wNx+LR7RzhjnJiUkFDhn18P5Bg/0VnJ/uXpRJM= +github.com/containerd/platforms v0.2.0 h1:clGNvVIcY3k39VJSYdFGohI1b3bP/eeBUVR5+XA28oo= +github.com/containerd/platforms v0.2.0/go.mod h1:XOM2BS6kN6gXafPLg80V6y/QUib+xoLyC3qVmHzibko= github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= github.com/containerd/ttrpc v0.0.0-20190828172938-92c8520ef9f8/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0xBw8r8NOKoOdNMeVHSawSsltak+Ihv+etqsE8= diff --git a/image.go b/image.go index a8f99c2b55..914ab35a70 100644 --- a/image.go +++ b/image.go @@ -29,10 +29,10 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" "github.com/containerd/containerd/pkg/kmutex" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/rootfs" "github.com/containerd/containerd/snapshots" "github.com/containerd/errdefs" + "github.com/containerd/platforms" "github.com/opencontainers/go-digest" "github.com/opencontainers/image-spec/identity" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/images/archive/exporter.go b/images/archive/exporter.go index 5d4aba40ab..016c147f39 100644 --- a/images/archive/exporter.go +++ b/images/archive/exporter.go @@ -29,9 +29,9 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" digest "github.com/opencontainers/go-digest" ocispecs "github.com/opencontainers/image-spec/specs-go" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/images/archive/importer.go b/images/archive/importer.go index e0c57728e6..fe6d451999 100644 --- a/images/archive/importer.go +++ b/images/archive/importer.go @@ -31,9 +31,9 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" digest "github.com/opencontainers/go-digest" specs "github.com/opencontainers/image-spec/specs-go" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/images/converter/converter.go b/images/converter/converter.go index 441e0169ef..4cacf90ba2 100644 --- a/images/converter/converter.go +++ b/images/converter/converter.go @@ -23,7 +23,7 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" "github.com/containerd/containerd/leases" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ) type convertOpts struct { diff --git a/images/converter/default.go b/images/converter/default.go index 4a887242ce..746bdd1ab1 100644 --- a/images/converter/default.go +++ b/images/converter/default.go @@ -26,7 +26,7 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/sirupsen/logrus" diff --git a/images/handlers.go b/images/handlers.go index 162e87a862..7a34cc5440 100644 --- a/images/handlers.go +++ b/images/handlers.go @@ -23,8 +23,8 @@ import ( "sort" "github.com/containerd/containerd/content" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" + "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "golang.org/x/sync/errgroup" "golang.org/x/sync/semaphore" diff --git a/images/image.go b/images/image.go index 3e2abc75f4..a13710e748 100644 --- a/images/image.go +++ b/images/image.go @@ -24,9 +24,9 @@ import ( "time" "github.com/containerd/containerd/content" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/import.go b/import.go index a6b918ba3d..1472f489e1 100644 --- a/import.go +++ b/import.go @@ -24,8 +24,8 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" "github.com/containerd/containerd/images/archive" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" + "github.com/containerd/platforms" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/integration/build_local_containerd_helper_test.go b/integration/build_local_containerd_helper_test.go index ec759dc97c..ae326e9cd8 100644 --- a/integration/build_local_containerd_helper_test.go +++ b/integration/build_local_containerd_helper_test.go @@ -26,11 +26,11 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/content" "github.com/containerd/containerd/pkg/cri/constants" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" ctrdsrv "github.com/containerd/containerd/services/server" srvconfig "github.com/containerd/containerd/services/server/config" "github.com/containerd/log/logtest" + "github.com/containerd/platforms" "github.com/opencontainers/go-digest" _ "github.com/containerd/containerd/diff/walking/plugin" diff --git a/integration/client/client_test.go b/integration/client/client_test.go index c38405c135..3d0e63c182 100644 --- a/integration/client/client_test.go +++ b/integration/client/client_test.go @@ -39,9 +39,9 @@ import ( "github.com/containerd/containerd/leases" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/testutil" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" ) var ( diff --git a/integration/client/client_unix_test.go b/integration/client/client_unix_test.go index 0d7b7d49f2..d45c655f97 100644 --- a/integration/client/client_unix_test.go +++ b/integration/client/client_unix_test.go @@ -23,7 +23,7 @@ import ( . "github.com/containerd/containerd" "github.com/containerd/containerd/integration/images" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ) var ( diff --git a/integration/client/container_test.go b/integration/client/container_test.go index da43fb40d2..4b5035acdf 100644 --- a/integration/client/container_test.go +++ b/integration/client/container_test.go @@ -38,7 +38,6 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/oci" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" gogotypes "github.com/containerd/containerd/protobuf/types" _ "github.com/containerd/containerd/runtime" @@ -47,6 +46,7 @@ import ( "github.com/containerd/errdefs" "github.com/containerd/go-runc" "github.com/containerd/log/logtest" + "github.com/containerd/platforms" "github.com/containerd/typeurl/v2" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/require" diff --git a/integration/client/convert_test.go b/integration/client/convert_test.go index a9246fd8b9..93364af156 100644 --- a/integration/client/convert_test.go +++ b/integration/client/convert_test.go @@ -23,7 +23,7 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/containerd/images/converter" "github.com/containerd/containerd/images/converter/uncompress" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/stretchr/testify/assert" ) diff --git a/integration/client/export_test.go b/integration/client/export_test.go index 73cd5fa088..85f2020bad 100644 --- a/integration/client/export_test.go +++ b/integration/client/export_test.go @@ -30,8 +30,8 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/containerd/images/archive" "github.com/containerd/containerd/namespaces" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" + "github.com/containerd/platforms" "github.com/google/uuid" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/integration/client/go.mod b/integration/client/go.mod index e5c16a66b2..e3ba9d8e75 100644 --- a/integration/client/go.mod +++ b/integration/client/go.mod @@ -12,6 +12,7 @@ require ( github.com/containerd/errdefs v0.1.0 github.com/containerd/go-runc v1.0.0 github.com/containerd/log v0.1.0 + github.com/containerd/platforms v0.2.0 github.com/containerd/ttrpc v1.2.4 github.com/containerd/typeurl/v2 v2.1.1 github.com/google/uuid v1.3.1 diff --git a/integration/client/go.sum b/integration/client/go.sum index 4dce7fe801..91926b924c 100644 --- a/integration/client/go.sum +++ b/integration/client/go.sum @@ -815,19 +815,24 @@ github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= +github.com/Microsoft/cosesign1go v0.0.1/go.mod h1:fj1svfAxQeQNJ2SLaQu8mHx2rtPIsloZl065GqLF3io= +github.com/Microsoft/didx509go v0.0.2/go.mod h1:F+msvNlKCEm3RgUE3kRpi7E+6hdR6r5PtOLWQKYfGbs= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00= github.com/Microsoft/hcsshim v0.8.20/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4= github.com/Microsoft/hcsshim v0.9.6/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= github.com/Microsoft/hcsshim v0.9.10/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= +github.com/Microsoft/hcsshim v0.10.0/go.mod h1:3j1trOamcUdi86J5Tr5+1BpqMjSv/QeRWkX2whBF6dY= github.com/Microsoft/hcsshim v0.11.5 h1:haEcLNpj9Ka1gd3B3tAEs9CpE0c+1IhoL59w/exYU38= github.com/Microsoft/hcsshim v0.11.5/go.mod h1:MV8xMfmECjl5HdO7U/3/hFVnkmSBjAjmA09d4bExKcU= github.com/Microsoft/hcsshim/test v0.0.0-20210408205431-da33ecd607e1 h1:pVKfKyPkXna29XlGjxSr9J0A7vNucOUHZ/2ClcTWalw= @@ -946,6 +951,7 @@ github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARu github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= +github.com/containerd/continuity v0.4.1/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM= github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= @@ -963,11 +969,15 @@ github.com/containerd/imgcrypt v1.1.8/go.mod h1:x6QvFIkMyO2qGIY2zXc88ivEzcbgvLdW github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/nri v0.6.1/go.mod h1:7+sX3wNx+LR7RzhjnJiUkFDhn18P5Bg/0VnJ/uXpRJM= +github.com/containerd/platforms v0.2.0 h1:clGNvVIcY3k39VJSYdFGohI1b3bP/eeBUVR5+XA28oo= +github.com/containerd/platforms v0.2.0/go.mod h1:XOM2BS6kN6gXafPLg80V6y/QUib+xoLyC3qVmHzibko= +github.com/containerd/protobuild v0.3.0/go.mod h1:5mNMFKKAwCIAkFBPiOdtRx2KiQlyEJeMXnL5R1DsWu8= github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM= github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o= github.com/containerd/ttrpc v1.0.2/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y= github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Evzy5KFQpQ= github.com/containerd/ttrpc v1.1.2/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Evzy5KFQpQ= +github.com/containerd/ttrpc v1.2.2/go.mod h1:sIT6l32Ph/H9cvnJsfXM5drIVzTr5A2flTf1G5tYZak= github.com/containerd/ttrpc v1.2.3/go.mod h1:ieWsXucbb8Mj9PH0rXCw1i8IunRbbAiDkpXkbfflWBM= github.com/containerd/ttrpc v1.2.4 h1:eQCQK4h9dxDmpOb9QOOMh2NHTfzroH1IkmHiKZi05Oo= github.com/containerd/ttrpc v1.2.4/go.mod h1:ojvb8SJBSch0XkqNO0L0YX/5NxR3UnVk2LzFKBK0upc= @@ -1005,6 +1015,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1SMSibvLzxjeJLnrYEVLULFNiHY9YfQ= @@ -1016,7 +1027,9 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d/go.mod h1:tmAIfUFEirG/Y8jhZ9M+h36obRZAk/1fcSpXwAVlfqE= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M= github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= @@ -1032,12 +1045,15 @@ github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017/go.mod h1:JLrzqnKDaYBop github.com/docker/cli v20.10.17+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v23.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v23.0.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v23.0.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v20.10.17+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v23.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v23.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v23.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= github.com/docker/docker-credential-helpers v0.6.4/go.mod h1:ofX3UI0Gz1TteYBjtgs07O36Pyasyp66D2uKT7H8W1c= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= @@ -1154,6 +1170,7 @@ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg78 github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -1236,6 +1253,7 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0= github.com/google/go-containerregistry v0.14.0/go.mod h1:aiJ2fp/SXvkWgmYHioXnbMdlgB8eXiiYOY55gfN91Wk= +github.com/google/go-containerregistry v0.15.2/go.mod h1:wWK+LnOv4jXMM23IT/F1wdYftGWGr47Is8CG+pmHK1Q= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -1370,6 +1388,7 @@ github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8 github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -1392,10 +1411,14 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y= github.com/lestrrat-go/blackmagic v1.0.0/go.mod h1:TNgH//0vYSs8VXDCfkZLgIrVTTXQELZffUV0tz3MtdQ= +github.com/lestrrat-go/blackmagic v1.0.1/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= github.com/lestrrat-go/iter v1.0.1/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbqPDrJ/OJc= +github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= github.com/lestrrat-go/jwx v1.2.25/go.mod h1:zoNuZymNl5lgdcu6P7K6ie2QRll5HVfF4xwxBBK1NxY= +github.com/lestrrat-go/jwx v1.2.26/go.mod h1:MaiCdGbn3/cckbOFSCluJlJMmp9dmZm5hDuIkx8ftpQ= github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= +github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo= github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= @@ -1458,6 +1481,7 @@ github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= github.com/moby/term v0.0.0-20210610120745-9d4ed1856297/go.mod h1:vgPCkQMyxTZ7IDy8SXRufE172gr8+K/JE/7hHFxHW3A= github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -1515,16 +1539,20 @@ github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zM github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= +github.com/opencontainers/image-spec v1.1.0-rc3/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= +github.com/opencontainers/runc v1.1.7/go.mod h1:CbUumNnWCuTGFukNXahoo/RFBZvDAgRh/smNYNOhA50= github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.0.3-0.20220909204839-494a5a6aca78/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opencontainers/runtime-spec v1.1.0-rc.3/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg= github.com/opencontainers/runtime-spec v1.1.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs= @@ -1539,6 +1567,7 @@ github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M5 github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= @@ -1651,6 +1680,7 @@ github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -1693,9 +1723,13 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8= +github.com/urfave/cli v1.22.13/go.mod h1:VufqObjsMTF2BBwKawpx9R8eAneNEWhoO0yx8Vd+FkE= +github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA= github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI= +github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY= github.com/vektah/gqlparser/v2 v2.4.5/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0= github.com/veraison/go-cose v1.0.0-rc.1/go.mod h1:7ziE85vSq4ScFTg6wyoMXjucIGOf4JkFEZi/an96Ct4= +github.com/veraison/go-cose v1.0.0/go.mod h1:7ziE85vSq4ScFTg6wyoMXjucIGOf4JkFEZi/an96Ct4= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= @@ -1703,6 +1737,7 @@ github.com/vishvananda/netlink v1.2.1-beta.2/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhg github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= +github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= @@ -1797,6 +1832,7 @@ go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= +go.uber.org/mock v0.2.0/go.mod h1:J0y0rp9L3xiff1+ZBfKxlC1fz2+aO16tw0tsDOixfuM= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= @@ -1825,6 +1861,7 @@ golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= @@ -2152,6 +2189,7 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2290,6 +2328,7 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= @@ -2576,6 +2615,7 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= @@ -2621,6 +2661,7 @@ google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSs google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0/go.mod h1:Dk1tviKTvMCz5tvh7t+fh94dhmQVHuCt2OzJB3CTW9Y= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/integration/client/image_test.go b/integration/client/image_test.go index 8367a7e6de..2411325fc8 100644 --- a/integration/client/image_test.go +++ b/integration/client/image_test.go @@ -27,8 +27,8 @@ import ( "github.com/containerd/containerd/images" imagelist "github.com/containerd/containerd/integration/images" "github.com/containerd/containerd/labels" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" + "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/integration/client/import_test.go b/integration/client/import_test.go index 2486fad98f..91dc07cc89 100644 --- a/integration/client/import_test.go +++ b/integration/client/import_test.go @@ -44,7 +44,7 @@ import ( "github.com/containerd/containerd/pkg/transfer" tarchive "github.com/containerd/containerd/pkg/transfer/archive" "github.com/containerd/containerd/pkg/transfer/image" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" "github.com/google/uuid" digest "github.com/opencontainers/go-digest" diff --git a/metrics/cgroups/cgroups.go b/metrics/cgroups/cgroups.go index 3137437579..b5eea9e531 100644 --- a/metrics/cgroups/cgroups.go +++ b/metrics/cgroups/cgroups.go @@ -23,9 +23,9 @@ import ( "github.com/containerd/containerd/events" v1 "github.com/containerd/containerd/metrics/cgroups/v1" v2 "github.com/containerd/containerd/metrics/cgroups/v2" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/runtime" + "github.com/containerd/platforms" metrics "github.com/docker/go-metrics" ) diff --git a/oci/spec.go b/oci/spec.go index b33ec19530..ec5f275ca2 100644 --- a/oci/spec.go +++ b/oci/spec.go @@ -27,7 +27,7 @@ import ( "github.com/containerd/containerd/containers" "github.com/containerd/containerd/namespaces" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ) const ( diff --git a/oci/spec_opts.go b/oci/spec_opts.go index cc8fab3ae0..33a08613ae 100644 --- a/oci/spec_opts.go +++ b/oci/spec_opts.go @@ -33,8 +33,8 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" - "github.com/containerd/containerd/platforms" "github.com/containerd/continuity/fs" + "github.com/containerd/platforms" "github.com/moby/sys/user" v1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/opencontainers/runtime-spec/specs-go" diff --git a/pkg/cri/cri.go b/pkg/cri/cri.go index a395db7acc..35ba615d21 100644 --- a/pkg/cri/cri.go +++ b/pkg/cri/cri.go @@ -32,10 +32,10 @@ import ( "github.com/containerd/containerd/pkg/cri/sbserver" "github.com/containerd/containerd/pkg/cri/server" nriservice "github.com/containerd/containerd/pkg/nri" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/services/warning" "github.com/containerd/log" + "github.com/containerd/platforms" ) // Register CRI service plugin diff --git a/pkg/cri/sbserver/container_create.go b/pkg/cri/sbserver/container_create.go index 985c34d106..7816717b23 100644 --- a/pkg/cri/sbserver/container_create.go +++ b/pkg/cri/sbserver/container_create.go @@ -43,8 +43,8 @@ import ( customopts "github.com/containerd/containerd/pkg/cri/opts" containerstore "github.com/containerd/containerd/pkg/cri/store/container" "github.com/containerd/containerd/pkg/cri/util" - "github.com/containerd/containerd/platforms" "github.com/containerd/log" + "github.com/containerd/platforms" ) func init() { diff --git a/pkg/cri/sbserver/container_create_linux_test.go b/pkg/cri/sbserver/container_create_linux_test.go index 3b7a64cc31..7076c31bc1 100644 --- a/pkg/cri/sbserver/container_create_linux_test.go +++ b/pkg/cri/sbserver/container_create_linux_test.go @@ -30,7 +30,7 @@ import ( "github.com/containerd/containerd/contrib/seccomp" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/oci" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/selinux/go-selinux" diff --git a/pkg/cri/sbserver/container_create_test.go b/pkg/cri/sbserver/container_create_test.go index 1463fc770d..6aef985d3a 100644 --- a/pkg/cri/sbserver/container_create_test.go +++ b/pkg/cri/sbserver/container_create_test.go @@ -25,7 +25,7 @@ import ( "testing" ostesting "github.com/containerd/containerd/pkg/os/testing" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtimespec "github.com/opencontainers/runtime-spec/specs-go" diff --git a/pkg/cri/sbserver/podsandbox/controller.go b/pkg/cri/sbserver/podsandbox/controller.go index 600e4048c3..7dcebf3612 100644 --- a/pkg/cri/sbserver/podsandbox/controller.go +++ b/pkg/cri/sbserver/podsandbox/controller.go @@ -33,10 +33,10 @@ import ( sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ctrdutil "github.com/containerd/containerd/pkg/cri/util" osinterface "github.com/containerd/containerd/pkg/os" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/sandbox" "github.com/containerd/errdefs" + "github.com/containerd/platforms" ) // CRIService interface contains things required by controller, but not yet refactored from criService. diff --git a/pkg/cri/sbserver/restart.go b/pkg/cri/sbserver/restart.go index b6246b7bf0..502a2cecee 100644 --- a/pkg/cri/sbserver/restart.go +++ b/pkg/cri/sbserver/restart.go @@ -30,9 +30,9 @@ import ( criconfig "github.com/containerd/containerd/pkg/cri/config" "github.com/containerd/containerd/pkg/cri/sbserver/podsandbox" "github.com/containerd/containerd/pkg/netns" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" "github.com/containerd/typeurl/v2" "golang.org/x/sync/errgroup" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/server/restart.go b/pkg/cri/server/restart.go index 5c75198a11..9af38fa7fa 100644 --- a/pkg/cri/server/restart.go +++ b/pkg/cri/server/restart.go @@ -27,9 +27,9 @@ import ( "github.com/containerd/containerd" containerdio "github.com/containerd/containerd/cio" containerdimages "github.com/containerd/containerd/images" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" "github.com/containerd/typeurl/v2" "golang.org/x/sync/errgroup" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/transfer/archive/exporter.go b/pkg/transfer/archive/exporter.go index 8a42e229eb..27fd837b1e 100644 --- a/pkg/transfer/archive/exporter.go +++ b/pkg/transfer/archive/exporter.go @@ -31,8 +31,8 @@ import ( "github.com/containerd/containerd/pkg/streaming" "github.com/containerd/containerd/pkg/transfer/plugins" tstreaming "github.com/containerd/containerd/pkg/transfer/streaming" - "github.com/containerd/containerd/platforms" "github.com/containerd/log" + "github.com/containerd/platforms" ) func init() { diff --git a/pkg/transfer/image/imagestore.go b/pkg/transfer/image/imagestore.go index 1d4aea8d1f..a7a6bbe611 100644 --- a/pkg/transfer/image/imagestore.go +++ b/pkg/transfer/image/imagestore.go @@ -31,9 +31,9 @@ import ( "github.com/containerd/containerd/pkg/streaming" "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/transfer/plugins" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/remotes" "github.com/containerd/errdefs" + "github.com/containerd/platforms" ) func init() { diff --git a/pkg/transfer/local/pull_test.go b/pkg/transfer/local/pull_test.go index 011dddf484..36ee19ca0e 100644 --- a/pkg/transfer/local/pull_test.go +++ b/pkg/transfer/local/pull_test.go @@ -22,7 +22,7 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/unpack" - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ) func TestGetSupportedPlatform(t *testing.T) { diff --git a/pkg/transfer/local/push.go b/pkg/transfer/local/push.go index e4883a48be..798a135810 100644 --- a/pkg/transfer/local/push.go +++ b/pkg/transfer/local/push.go @@ -25,9 +25,9 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/transfer" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/remotes" "github.com/containerd/errdefs" + "github.com/containerd/platforms" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/pkg/unpack/unpacker.go b/pkg/unpack/unpacker.go index 22f6fac4bb..76e24f7636 100644 --- a/pkg/unpack/unpacker.go +++ b/pkg/unpack/unpacker.go @@ -35,11 +35,11 @@ import ( "github.com/containerd/containerd/mount" "github.com/containerd/containerd/pkg/cleanup" "github.com/containerd/containerd/pkg/kmutex" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/tracing" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" "github.com/opencontainers/go-digest" "github.com/opencontainers/image-spec/identity" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/platforms/compare_test.go b/platforms/compare_test.go deleted file mode 100644 index cbe90deead..0000000000 --- a/platforms/compare_test.go +++ /dev/null @@ -1,415 +0,0 @@ -/* - 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 ( - "testing" -) - -func TestOnly(t *testing.T) { - for _, tc := range []struct { - platform string - matches map[bool][]string - }{ - { - platform: "linux/amd64", - matches: map[bool][]string{ - true: { - "linux/amd64", - "linux/386", - }, - false: { - "linux/amd64/v2", - "linux/arm/v7", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/amd64/v2", - matches: map[bool][]string{ - true: { - "linux/amd64", - "linux/amd64/v1", - "linux/amd64/v2", - "linux/386", - }, - false: { - "linux/amd64/v3", - "linux/amd64/v4", - "linux/arm/v7", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/386", - matches: map[bool][]string{ - true: { - "linux/386", - }, - false: { - "linux/amd64", - "linux/arm/v7", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "windows/amd64", - matches: map[bool][]string{ - true: {"windows/amd64"}, - false: { - "linux/amd64", - "linux/arm/v7", - "linux/arm64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm/v8", - matches: map[bool][]string{ - true: { - "linux/arm", - "linux/arm/v5", - "linux/arm/v6", - "linux/arm/v7", - "linux/arm/v8", - }, - false: { - "linux/amd64", - "linux/arm/v4", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm/v7", - matches: map[bool][]string{ - true: { - "linux/arm", - "linux/arm/v5", - "linux/arm/v6", - "linux/arm/v7", - }, - false: { - "linux/amd64", - "linux/arm/v4", - "linux/arm/v8", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm/v6", - matches: map[bool][]string{ - true: { - "linux/arm/v5", - "linux/arm/v6", - }, - false: { - "linux/amd64", - "linux/arm", - "linux/arm/v4", - "linux/arm/v7", - "linux/arm/v8", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm/v5", - matches: map[bool][]string{ - true: { - "linux/arm/v5", - }, - false: { - "linux/amd64", - "linux/arm", - "linux/arm/v4", - "linux/arm/v6", - "linux/arm/v7", - "linux/arm/v8", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm/v4", - matches: map[bool][]string{ - true: { - "linux/arm/v4", - }, - false: { - "linux/amd64", - "linux/arm", - "linux/arm/v5", - "linux/arm/v6", - "linux/arm/v7", - "linux/arm/v8", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm64", - matches: map[bool][]string{ - true: { - "linux/arm", - "linux/arm/v5", - "linux/arm/v6", - "linux/arm/v7", - "linux/arm/v8", - "linux/arm64", - "linux/arm64/v8", - }, - false: { - "linux/amd64", - "linux/arm/v4", - "linux/arm/v9", - "linux/arm64/v9", - "windows/amd64", - "windows/arm", - }, - }, - }, - } { - testcase := tc - t.Run(testcase.platform, func(t *testing.T) { - p, err := Parse(testcase.platform) - if err != nil { - t.Fatal(err) - } - m := Only(p) - for shouldMatch, platforms := range testcase.matches { - for _, matchPlatform := range platforms { - mp, err := Parse(matchPlatform) - if err != nil { - t.Fatal(err) - } - if match := m.Match(mp); shouldMatch != match { - t.Errorf("Only(%q).Match(%q) should return %v, but returns %v", testcase.platform, matchPlatform, shouldMatch, match) - } - } - } - }) - } -} - -func TestOnlyStrict(t *testing.T) { - for _, tc := range []struct { - platform string - matches map[bool][]string - }{ - { - platform: "linux/amd64", - matches: map[bool][]string{ - true: { - "linux/amd64", - }, - false: { - "linux/386", - "linux/arm/v7", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/386", - matches: map[bool][]string{ - true: { - "linux/386", - }, - false: { - "linux/amd64", - "linux/arm/v7", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "windows/amd64", - matches: map[bool][]string{ - true: {"windows/amd64"}, - false: { - "linux/amd64", - "linux/arm/v7", - "linux/arm64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm/v8", - matches: map[bool][]string{ - true: { - "linux/arm/v8", - }, - false: { - "linux/arm", - "linux/arm/v5", - "linux/arm/v6", - "linux/arm/v7", - "linux/amd64", - "linux/arm/v4", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm/v7", - matches: map[bool][]string{ - true: { - "linux/arm", - "linux/arm/v7", - }, - false: { - "linux/arm/v5", - "linux/arm/v6", - "linux/amd64", - "linux/arm/v4", - "linux/arm/v8", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm/v6", - matches: map[bool][]string{ - true: { - "linux/arm/v6", - }, - false: { - "linux/arm/v5", - "linux/amd64", - "linux/arm", - "linux/arm/v4", - "linux/arm/v7", - "linux/arm/v8", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm/v5", - matches: map[bool][]string{ - true: { - "linux/arm/v5", - }, - false: { - "linux/amd64", - "linux/arm", - "linux/arm/v4", - "linux/arm/v6", - "linux/arm/v7", - "linux/arm/v8", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm/v4", - matches: map[bool][]string{ - true: { - "linux/arm/v4", - }, - false: { - "linux/amd64", - "linux/arm", - "linux/arm/v5", - "linux/arm/v6", - "linux/arm/v7", - "linux/arm/v8", - "linux/arm64", - "windows/amd64", - "windows/arm", - }, - }, - }, - { - platform: "linux/arm64", - matches: map[bool][]string{ - true: { - "linux/arm64", - "linux/arm64/v8", - }, - false: { - "linux/arm", - "linux/arm/v5", - "linux/arm/v6", - "linux/arm/v7", - "linux/arm/v8", - "linux/amd64", - "linux/arm/v4", - "linux/arm/v9", - "linux/arm64/v9", - "windows/amd64", - "windows/arm", - }, - }, - }, - } { - testcase := tc - t.Run(testcase.platform, func(t *testing.T) { - p, err := Parse(testcase.platform) - if err != nil { - t.Fatal(err) - } - m := OnlyStrict(p) - for shouldMatch, platforms := range testcase.matches { - for _, matchPlatform := range platforms { - mp, err := Parse(matchPlatform) - if err != nil { - t.Fatal(err) - } - if match := m.Match(mp); shouldMatch != match { - t.Errorf("OnlyStrict(%q).Match(%q) should return %v, but returns %v", testcase.platform, matchPlatform, shouldMatch, match) - } - } - } - }) - } -} diff --git a/platforms/cpuinfo_linux_test.go b/platforms/cpuinfo_linux_test.go deleted file mode 100644 index b324e7398a..0000000000 --- a/platforms/cpuinfo_linux_test.go +++ /dev/null @@ -1,141 +0,0 @@ -/* - 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 ( - "errors" - "runtime" - "testing" - - "github.com/containerd/errdefs" -) - -func TestCPUVariant(t *testing.T) { - if !isArmArch(runtime.GOARCH) { - t.Skip("only relevant on linux/arm") - } - - variants := []string{"v8", "v7", "v6", "v5", "v4", "v3"} - - p, err := getCPUVariant() - if err != nil { - t.Fatalf("Error getting CPU variant: %v", err) - return - } - - for _, variant := range variants { - if p == variant { - t.Logf("got valid variant as expected: %#v = %#v", p, variant) - return - } - } - - t.Fatalf("could not get valid variant as expected: %v", variants) -} - -func TestGetCPUVariantFromArch(t *testing.T) { - - for _, testcase := range []struct { - name string - input string - output string - expectedErr error - }{ - { - name: "Test aarch64", - input: "aarch64", - output: "8", - expectedErr: nil, - }, - { - name: "Test Armv8 with capital", - input: "Armv8", - output: "8", - expectedErr: nil, - }, - { - name: "Test armv7", - input: "armv7", - output: "7", - expectedErr: nil, - }, - { - name: "Test armv6", - input: "armv6", - output: "6", - expectedErr: nil, - }, - { - name: "Test armv5", - input: "armv5", - output: "5", - expectedErr: nil, - }, - { - name: "Test armv4", - input: "armv4", - output: "4", - expectedErr: nil, - }, - { - name: "Test armv3", - input: "armv3", - output: "3", - expectedErr: nil, - }, - { - name: "Test unknown input", - input: "armv9", - output: "unknown", - expectedErr: nil, - }, - { - name: "Test invalid input which doesn't start with armv", - input: "armxxxx", - output: "", - expectedErr: errdefs.ErrInvalidArgument, - }, - { - name: "Test invalid input whose length is less than 5", - input: "armv", - output: "", - expectedErr: errdefs.ErrInvalidArgument, - }, - } { - t.Run(testcase.name, func(t *testing.T) { - t.Logf("input: %v", testcase.input) - - variant, err := getCPUVariantFromArch(testcase.input) - - if err == nil { - if testcase.expectedErr != nil { - t.Fatalf("Expect to get error: %v, however no error got", testcase.expectedErr) - } else { - if variant != testcase.output { - t.Fatalf("Expect to get variant: %v, however %v returned", testcase.output, variant) - } - } - - } else { - if !errors.Is(err, testcase.expectedErr) { - t.Fatalf("Expect to get error: %v, however error %v returned", testcase.expectedErr, err) - } - } - }) - - } -} diff --git a/platforms/defaults_windows_test.go b/platforms/defaults_windows_test.go deleted file mode 100644 index ab73ddda07..0000000000 --- a/platforms/defaults_windows_test.go +++ /dev/null @@ -1,374 +0,0 @@ -/* - 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 ( - "fmt" - "reflect" - "runtime" - "sort" - "testing" - - imagespec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/stretchr/testify/assert" - "golang.org/x/sys/windows" -) - -func TestDefault(t *testing.T) { - major, minor, build := windows.RtlGetNtVersionNumbers() - expected := imagespec.Platform{ - OS: runtime.GOOS, - Architecture: runtime.GOARCH, - OSVersion: fmt.Sprintf("%d.%d.%d", major, minor, build), - Variant: cpuVariant(), - } - p := DefaultSpec() - if !reflect.DeepEqual(p, expected) { - t.Fatalf("default platform not as expected: %#v != %#v", p, expected) - } - - s := DefaultString() - if s != Format(p) { - t.Fatalf("default specifier should match formatted default spec: %v != %v", s, p) - } -} - -func TestDefaultMatchComparer(t *testing.T) { - defaultMatcher := Default() - - for _, test := range []struct { - platform imagespec.Platform - match bool - }{ - { - platform: DefaultSpec(), - match: true, - }, - { - platform: imagespec.Platform{ - OS: "linux", - Architecture: runtime.GOARCH, - }, - match: false, - }, - } { - assert.Equal(t, test.match, defaultMatcher.Match(test.platform)) - } - -} - -func TestMatchComparerMatch_WCOW(t *testing.T) { - major, minor, build := windows.RtlGetNtVersionNumbers() - buildStr := fmt.Sprintf("%d.%d.%d", major, minor, build) - m := windowsmatcher{ - Platform: DefaultSpec(), - osVersionPrefix: buildStr, - defaultMatcher: &matcher{ - Platform: Normalize(DefaultSpec()), - }, - } - for _, test := range []struct { - platform imagespec.Platform - match bool - }{ - { - platform: DefaultSpec(), - match: true, - }, - { - platform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: buildStr + ".1", - }, - match: true, - }, - { - platform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: buildStr + ".2", - }, - match: true, - }, - { - platform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - // Use an nonexistent Windows build so we don't get a match. Ws2019's build is 17763/ - OSVersion: "10.0.17762.1", - }, - match: false, - }, - { - platform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - // Use an nonexistent Windows build so we don't get a match. Ws2019's build is 17763/ - OSVersion: "10.0.17764.1", - }, - match: false, - }, - { - platform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - }, - match: true, - }, - { - platform: imagespec.Platform{ - Architecture: "amd64", - OS: "linux", - }, - match: false, - }, - } { - assert.Equal(t, test.match, m.Match(test.platform), "should match: %t, %s to %s", test.match, m.Platform, test.platform) - } -} - -// TestMatchComparerMatch_ABICheckWCOW checks windows platform matcher -// behavior for stable ABI and non-stable ABI compliant versions -func TestMatchComparerMatch_ABICheckWCOW(t *testing.T) { - platformWS2019 := imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17763", - } - platformWS2022 := imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.20348", - } - platformWindows11 := imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.22621", - } - matcherWS2019 := windowsmatcher{ - Platform: platformWS2019, - osVersionPrefix: platformWS2019.OSVersion, - defaultMatcher: &matcher{ - Platform: Normalize(platformWS2019), - }, - } - matcherWS2022 := windowsmatcher{ - Platform: platformWS2022, - osVersionPrefix: platformWS2022.OSVersion, - defaultMatcher: &matcher{ - Platform: Normalize(platformWS2022), - }, - } - matcherWindows11 := windowsmatcher{ - Platform: platformWindows11, - osVersionPrefix: platformWindows11.OSVersion, - defaultMatcher: &matcher{ - Platform: Normalize(platformWindows11), - }, - } - - for _, test := range []struct { - hostPlatformMatcher windowsmatcher - testPlatform imagespec.Platform - match bool - }{ - { - hostPlatformMatcher: matcherWS2019, - testPlatform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17763", - }, - match: true, - }, - { - hostPlatformMatcher: matcherWS2019, - testPlatform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.20348", - }, - match: false, - }, - { - hostPlatformMatcher: matcherWS2022, - testPlatform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17763", - }, - match: false, - }, - { - hostPlatformMatcher: matcherWS2022, - testPlatform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.20348", - }, - match: true, - }, - { - hostPlatformMatcher: matcherWindows11, - testPlatform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17763", - }, - match: false, - }, - { - hostPlatformMatcher: matcherWindows11, - testPlatform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.20348", - }, - match: true, - }, - } { - assert.Equal(t, test.match, test.hostPlatformMatcher.Match(test.testPlatform), "should match: %t, %s to %s", test.match, test.hostPlatformMatcher.Platform, test.testPlatform) - } -} - -func TestMatchComparerMatch_LCOW(t *testing.T) { - major, minor, build := windows.RtlGetNtVersionNumbers() - buildStr := fmt.Sprintf("%d.%d.%d", major, minor, build) - m := windowsmatcher{ - Platform: imagespec.Platform{ - OS: "linux", - Architecture: "amd64", - }, - osVersionPrefix: "", - defaultMatcher: &matcher{ - Platform: Normalize(imagespec.Platform{ - OS: "linux", - Architecture: "amd64", - }, - ), - }, - } - for _, test := range []struct { - platform imagespec.Platform - match bool - }{ - { - platform: DefaultSpec(), - match: false, - }, - { - platform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - }, - match: false, - }, - { - platform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - OSVersion: buildStr + ".2", - }, - match: false, - }, - { - platform: imagespec.Platform{ - Architecture: "amd64", - OS: "windows", - // Use an nonexistent Windows build so we don't get a match. Ws2019's build is 17763/ - OSVersion: "10.0.17762.1", - }, - match: false, - }, - { - platform: imagespec.Platform{ - Architecture: "amd64", - OS: "linux", - }, - match: true, - }, - } { - assert.Equal(t, test.match, m.Match(test.platform), "should match %b, %s to %s", test.match, m.Platform, test.platform) - } -} - -func TestMatchComparerLess(t *testing.T) { - m := windowsmatcher{ - Platform: DefaultSpec(), - osVersionPrefix: "10.0.17763", - defaultMatcher: &matcher{ - Platform: Normalize(DefaultSpec()), - }, - } - platforms := []imagespec.Platform{ - { - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17764.1", - }, - { - Architecture: "amd64", - OS: "windows", - }, - { - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17763.1", - }, - { - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17763.2", - }, - { - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17762.1", - }, - } - expected := []imagespec.Platform{ - { - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17763.2", - }, - { - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17763.1", - }, - { - Architecture: "amd64", - OS: "windows", - }, - { - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17764.1", - }, - { - Architecture: "amd64", - OS: "windows", - OSVersion: "10.0.17762.1", - }, - } - sort.SliceStable(platforms, func(i, j int) bool { - return m.Less(platforms[i], platforms[j]) - }) - assert.Equal(t, expected, platforms) -} diff --git a/platforms/platforms_deprecated.go b/platforms/platforms_deprecated.go new file mode 100644 index 0000000000..e48f8e0e52 --- /dev/null +++ b/platforms/platforms_deprecated.go @@ -0,0 +1,138 @@ +/* + 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 ( + "github.com/containerd/platforms" + specs "github.com/opencontainers/image-spec/specs-go/v1" +) + +// Platform is a type alias for convenience, so there is no need to import image-spec package everywhere. +type Platform = specs.Platform + +// DefaultSpec returns the current platform's default platform specification. +func DefaultSpec() specs.Platform { + return platforms.DefaultSpec() +} + +// Default returns the default matcher for the platform. +func Default() platforms.MatchComparer { + return platforms.Default() +} + +// DefaultString returns the default string specifier for the platform. +func DefaultString() string { + return platforms.DefaultString() +} + +// DefaultStrict returns strict form of Default. +func DefaultStrict() MatchComparer { + return platforms.DefaultStrict() +} + +// MatchComparer is able to match and compare platforms to +// filter and sort platforms. +type MatchComparer = platforms.MatchComparer + +// Matcher matches platforms specifications, provided by an image or runtime. +type Matcher = platforms.Matcher + +// NewMatcher returns a simple matcher based on the provided platform +// specification. The returned matcher only looks for equality based on os, +// architecture and variant. +// +// One may implement their own matcher if this doesn't provide the required +// functionality. +// +// Applications should opt to use `Match` over directly parsing specifiers. +func NewMatcher(platform specs.Platform) platforms.Matcher { + return platforms.NewMatcher(platform) +} + +// Parse parses the platform specifier syntax into a platform declaration. +// +// Platform specifiers are in the format `||/[/]`. +// The minimum required information for a platform specifier is the operating +// system or architecture. If there is only a single string (no slashes), the +// value will be matched against the known set of operating systems, then fall +// back to the known set of architectures. The missing component will be +// inferred based on the local environment. +func Parse(specifier string) (specs.Platform, error) { + return platforms.Parse(specifier) +} + +// MustParse is like Parses but panics if the specifier cannot be parsed. +// Simplifies initialization of global variables. +func MustParse(specifier string) specs.Platform { + return platforms.MustParse(specifier) +} + +// Format returns a string specifier from the provided platform specification. +func Format(platform specs.Platform) string { + return platforms.Format(platform) +} + +// Normalize validates and translate the platform to the canonical value. +// +// For example, if "Aarch64" is encountered, we change it to "arm64" or if +// "x86_64" is encountered, it becomes "amd64". +func Normalize(platform specs.Platform) specs.Platform { + return platforms.Normalize(platform) +} + +// Only returns a match comparer for a single platform +// using default resolution logic for the platform. +// +// For arm/v8, will also match arm/v7, arm/v6 and arm/v5 +// For arm/v7, will also match arm/v6 and arm/v5 +// For arm/v6, will also match arm/v5 +// For amd64, will also match 386 +func Only(platform specs.Platform) platforms.MatchComparer { + return platforms.Only(platform) +} + +// OnlyStrict returns a match comparer for a single platform. +// +// Unlike Only, OnlyStrict does not match sub platforms. +// So, "arm/vN" will not match "arm/vM" where M < N, +// and "amd64" will not also match "386". +// +// OnlyStrict matches non-canonical forms. +// So, "arm64" matches "arm/64/v8". +func OnlyStrict(platform specs.Platform) platforms.MatchComparer { + return platforms.OnlyStrict(platform) +} + +// Ordered returns a platform MatchComparer which matches any of the platforms +// but orders them in order they are provided. +func Ordered(platform ...specs.Platform) platforms.MatchComparer { + return platforms.Ordered(platform...) +} + +// Any returns a platform MatchComparer which matches any of the platforms +// with no preference for ordering. +func Any(platform ...specs.Platform) platforms.MatchComparer { + return platforms.Any(platform...) +} + +// All is a platform MatchComparer which matches all platforms +// with preference for ordering. +var All = platforms.All + +func GetWindowsOsVersion() string { + return getWindowsOsVersion() +} diff --git a/platforms/platforms_windows_test.go b/platforms/platforms_deprecated_other.go similarity index 55% rename from platforms/platforms_windows_test.go rename to platforms/platforms_deprecated_other.go index d5f3883f60..0d17529ecd 100644 --- a/platforms/platforms_windows_test.go +++ b/platforms/platforms_deprecated_other.go @@ -1,3 +1,5 @@ +//go:build !windows + /* Copyright The containerd Authors. @@ -16,26 +18,6 @@ package platforms -import ( - "testing" - - specs "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/stretchr/testify/require" -) - -func TestNormalize(t *testing.T) { - require.Equal(t, DefaultSpec(), Normalize(DefaultSpec())) -} - -func TestFallbackOnOSVersion(t *testing.T) { - p := specs.Platform{ - OS: "windows", - Architecture: "amd64", - OSVersion: "99.99.99.99", - } - - other := specs.Platform{OS: p.OS, Architecture: p.Architecture} - - m := NewMatcher(p) - require.True(t, m.Match(other)) +func getWindowsOsVersion() string { + return "" } diff --git a/platforms/platforms_deprecated_windows.go b/platforms/platforms_deprecated_windows.go new file mode 100644 index 0000000000..9815415c75 --- /dev/null +++ b/platforms/platforms_deprecated_windows.go @@ -0,0 +1,48 @@ +/* + 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 ( + "fmt" + "strconv" + "strings" + + "github.com/Microsoft/hcsshim/osversion" + "golang.org/x/sys/windows" +) + +func getWindowsOsVersion() string { + major, minor, build := windows.RtlGetNtVersionNumbers() + return fmt.Sprintf("%d.%d.%d", major, minor, build) +} + +func GetOsVersion(osVersionPrefix string) osversion.OSVersion { + parts := strings.Split(osVersionPrefix, ".") + if len(parts) < 3 { + return osversion.OSVersion{} + } + + majorVersion, _ := strconv.Atoi(parts[0]) + minorVersion, _ := strconv.Atoi(parts[1]) + buildNumber, _ := strconv.Atoi(parts[2]) + + return osversion.OSVersion{ + MajorVersion: uint8(majorVersion), + MinorVersion: uint8(minorVersion), + Build: uint16(buildNumber), + } +} diff --git a/platforms/platforms_test.go b/platforms/platforms_test.go deleted file mode 100644 index c2af02178b..0000000000 --- a/platforms/platforms_test.go +++ /dev/null @@ -1,376 +0,0 @@ -/* - 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 ( - "path" - "reflect" - "runtime" - "testing" - - specs "github.com/opencontainers/image-spec/specs-go/v1" -) - -func TestParseSelector(t *testing.T) { - var ( - defaultOS = runtime.GOOS - defaultArch = runtime.GOARCH - defaultVariant = "" - ) - - if defaultArch == "arm" && cpuVariant() != "v7" { - defaultVariant = cpuVariant() - } - - for _, testcase := range []struct { - skip bool - input string - expected specs.Platform - matches []specs.Platform - formatted string - }{ - // While wildcards are a valid use case for platform selection, - // addressing these cases is outside the initial scope for this - // package. When we do add platform wildcards, we should add in these - // testcases to ensure that they are correctly represented. - { - skip: true, - input: "*", - expected: specs.Platform{ - OS: "*", - Architecture: "*", - }, - formatted: "*/*", - }, - { - skip: true, - input: "linux/*", - expected: specs.Platform{ - OS: "linux", - Architecture: "*", - }, - formatted: "linux/*", - }, - { - skip: true, - input: "*/arm64", - expected: specs.Platform{ - OS: "*", - Architecture: "arm64", - }, - matches: []specs.Platform{ - { - OS: "*", - Architecture: "aarch64", - }, - { - OS: "*", - Architecture: "aarch64", - Variant: "v8", - }, - { - OS: "*", - Architecture: "arm64", - Variant: "v8", - }, - }, - formatted: "*/arm64", - }, - { - input: "linux/arm64", - expected: specs.Platform{ - OS: "linux", - Architecture: "arm64", - }, - matches: []specs.Platform{ - { - OS: "linux", - Architecture: "aarch64", - }, - { - OS: "linux", - Architecture: "aarch64", - Variant: "v8", - }, - { - OS: "linux", - Architecture: "arm64", - Variant: "v8", - }, - }, - formatted: "linux/arm64", - }, - { - input: "linux/arm64/v8", - expected: specs.Platform{ - OS: "linux", - Architecture: "arm64", - Variant: "v8", - }, - matches: []specs.Platform{ - { - OS: "linux", - Architecture: "aarch64", - }, - { - OS: "linux", - Architecture: "aarch64", - Variant: "v8", - }, - { - OS: "linux", - Architecture: "arm64", - }, - }, - formatted: "linux/arm64/v8", - }, - { - // NOTE(stevvooe): In this case, the consumer can assume this is v7 - // but we leave the variant blank. This will represent the vast - // majority of arm images. - input: "linux/arm", - expected: specs.Platform{ - OS: "linux", - Architecture: "arm", - }, - matches: []specs.Platform{ - { - OS: "linux", - Architecture: "arm", - Variant: "v7", - }, - { - OS: "linux", - Architecture: "armhf", - }, - { - OS: "linux", - Architecture: "arm", - Variant: "7", - }, - }, - formatted: "linux/arm", - }, - { - input: "linux/arm/v6", - expected: specs.Platform{ - OS: "linux", - Architecture: "arm", - Variant: "v6", - }, - matches: []specs.Platform{ - { - OS: "linux", - Architecture: "armel", - }, - }, - formatted: "linux/arm/v6", - }, - { - input: "linux/arm/v7", - expected: specs.Platform{ - OS: "linux", - Architecture: "arm", - Variant: "v7", - }, - matches: []specs.Platform{ - { - OS: "linux", - Architecture: "arm", - }, - { - OS: "linux", - Architecture: "armhf", - }, - }, - formatted: "linux/arm/v7", - }, - { - input: "arm", - expected: specs.Platform{ - OS: defaultOS, - Architecture: "arm", - }, - formatted: path.Join(defaultOS, "arm"), - }, - { - input: "armel", - expected: specs.Platform{ - OS: defaultOS, - Architecture: "arm", - Variant: "v6", - }, - formatted: path.Join(defaultOS, "arm/v6"), - }, - { - input: "armhf", - expected: specs.Platform{ - OS: defaultOS, - Architecture: "arm", - }, - formatted: path.Join(defaultOS, "arm"), - }, - { - input: "Aarch64", - expected: specs.Platform{ - OS: defaultOS, - Architecture: "arm64", - }, - formatted: path.Join(defaultOS, "arm64"), - }, - { - input: "x86_64", - expected: specs.Platform{ - OS: defaultOS, - Architecture: "amd64", - }, - formatted: path.Join(defaultOS, "amd64"), - }, - { - input: "Linux/x86_64", - expected: specs.Platform{ - OS: "linux", - Architecture: "amd64", - }, - formatted: "linux/amd64", - }, - { - input: "i386", - expected: specs.Platform{ - OS: defaultOS, - Architecture: "386", - }, - formatted: path.Join(defaultOS, "386"), - }, - { - input: "linux", - expected: specs.Platform{ - OS: "linux", - Architecture: defaultArch, - Variant: defaultVariant, - }, - formatted: path.Join("linux", defaultArch, defaultVariant), - }, - { - input: "s390x", - expected: specs.Platform{ - OS: defaultOS, - Architecture: "s390x", - }, - formatted: path.Join(defaultOS, "s390x"), - }, - { - input: "linux/s390x", - expected: specs.Platform{ - OS: "linux", - Architecture: "s390x", - }, - formatted: "linux/s390x", - }, - { - input: "macOS", - expected: specs.Platform{ - OS: "darwin", - Architecture: defaultArch, - Variant: defaultVariant, - }, - formatted: path.Join("darwin", defaultArch, defaultVariant), - }, - } { - t.Run(testcase.input, func(t *testing.T) { - if testcase.skip { - t.Skip("this case is not yet supported") - } - p, err := Parse(testcase.input) - if err != nil { - t.Fatal(err) - } - - if !reflect.DeepEqual(p, testcase.expected) { - t.Fatalf("platform did not match expected: %#v != %#v", p, testcase.expected) - } - - m := NewMatcher(p) - - // ensure that match works on the input to the output. - if ok := m.Match(testcase.expected); !ok { - t.Fatalf("expected specifier %q matches %#v", testcase.input, testcase.expected) - } - for _, mc := range testcase.matches { - if ok := m.Match(mc); !ok { - t.Fatalf("expected specifier %q matches %#v", testcase.input, mc) - } - } - - formatted := Format(p) - if formatted != testcase.formatted { - t.Fatalf("unexpected format: %q != %q", formatted, testcase.formatted) - } - - // re-parse the formatted output and ensure we are stable - reparsed, err := Parse(formatted) - if err != nil { - t.Fatalf("error parsing formatted output: %v", err) - } - - if Format(reparsed) != formatted { - t.Fatalf("normalized output did not survive the round trip: %v != %v", Format(reparsed), formatted) - } - }) - } -} - -func TestParseSelectorInvalid(t *testing.T) { - for _, testcase := range []struct { - input string - }{ - { - input: "", // empty - }, - { - input: "/linux/arm", // leading slash - }, - { - input: "linux/arm/", // trailing slash - }, - { - input: "linux /arm", // spaces - }, - { - input: "linux/&arm", // invalid character - }, - { - input: "linux/arm/foo/bar", // too many components - }, - } { - t.Run(testcase.input, func(t *testing.T) { - if _, err := Parse(testcase.input); err == nil { - t.Fatalf("should have received an error") - } - }) - } -} - -func FuzzPlatformsParse(f *testing.F) { - f.Add("linux/amd64") - f.Fuzz(func(t *testing.T, s string) { - pf, err := Parse(s) - if err != nil && (pf.OS != "" || pf.Architecture != "") { - t.Errorf("either %+v or %+v must be nil", err, pf) - } - }) -} diff --git a/plugins/transfer/plugin.go b/plugins/transfer/plugin.go index 91d948b4af..51e39e18ce 100644 --- a/plugins/transfer/plugin.go +++ b/plugins/transfer/plugin.go @@ -25,10 +25,10 @@ import ( "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/pkg/transfer/local" "github.com/containerd/containerd/pkg/unpack" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" // Load packages with type registrations _ "github.com/containerd/containerd/pkg/transfer/archive" diff --git a/pull.go b/pull.go index 0e2911d5f5..75feb764ae 100644 --- a/pull.go +++ b/pull.go @@ -26,12 +26,12 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/unpack" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/remotes/docker/schema1" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. "github.com/containerd/containerd/tracing" "github.com/containerd/errdefs" + "github.com/containerd/platforms" ) const ( diff --git a/remotes/handlers.go b/remotes/handlers.go index 912b85bfe8..736a044c73 100644 --- a/remotes/handlers.go +++ b/remotes/handlers.go @@ -28,9 +28,9 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" - "github.com/containerd/containerd/platforms" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "golang.org/x/sync/semaphore" ) diff --git a/runtime/v1/linux/runtime.go b/runtime/v1/linux/runtime.go index 71a8ed8bc4..ab3f024875 100644 --- a/runtime/v1/linux/runtime.go +++ b/runtime/v1/linux/runtime.go @@ -37,7 +37,6 @@ import ( "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/cleanup" "github.com/containerd/containerd/pkg/process" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" @@ -48,6 +47,7 @@ import ( "github.com/containerd/errdefs" "github.com/containerd/go-runc" "github.com/containerd/log" + "github.com/containerd/platforms" "github.com/containerd/typeurl/v2" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "golang.org/x/sys/unix" diff --git a/runtime/v2/manager.go b/runtime/v2/manager.go index 915c448e4b..80c7d68314 100644 --- a/runtime/v2/manager.go +++ b/runtime/v2/manager.go @@ -31,7 +31,6 @@ import ( "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/cleanup" "github.com/containerd/containerd/pkg/timeout" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/runtime" @@ -39,6 +38,7 @@ import ( "github.com/containerd/containerd/sandbox" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/runtime/v2/manager_unix.go b/runtime/v2/manager_unix.go index df2559afd8..be6ce6e112 100644 --- a/runtime/v2/manager_unix.go +++ b/runtime/v2/manager_unix.go @@ -19,7 +19,7 @@ package v2 import ( - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ) func defaultPlatforms() []string { diff --git a/runtime/v2/manager_windows.go b/runtime/v2/manager_windows.go index fe2040daf4..b1bfbaa488 100644 --- a/runtime/v2/manager_windows.go +++ b/runtime/v2/manager_windows.go @@ -17,7 +17,7 @@ package v2 import ( - "github.com/containerd/containerd/platforms" + "github.com/containerd/platforms" ) func defaultPlatforms() []string { diff --git a/services/server/server.go b/services/server/server.go index de38418fb6..1ede2d67a4 100644 --- a/services/server/server.go +++ b/services/server/server.go @@ -57,13 +57,13 @@ import ( "github.com/containerd/containerd/pkg/deprecation" "github.com/containerd/containerd/pkg/dialer" "github.com/containerd/containerd/pkg/timeout" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" srvconfig "github.com/containerd/containerd/services/server/config" "github.com/containerd/containerd/services/warning" ssproxy "github.com/containerd/containerd/snapshots/proxy" "github.com/containerd/containerd/sys" "github.com/containerd/log" + "github.com/containerd/platforms" ) // CreateTopLevelDirectories creates the top-level root and state directories. diff --git a/snapshots/blockfile/plugin/plugin.go b/snapshots/blockfile/plugin/plugin.go index a9de3a6159..6e4cd0b97f 100644 --- a/snapshots/blockfile/plugin/plugin.go +++ b/snapshots/blockfile/plugin/plugin.go @@ -19,9 +19,9 @@ package plugin import ( "errors" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots/blockfile" + "github.com/containerd/platforms" ) // Config represents configuration for the native plugin. diff --git a/snapshots/btrfs/plugin/plugin.go b/snapshots/btrfs/plugin/plugin.go index 4cc9a0d1c2..c91715eb79 100644 --- a/snapshots/btrfs/plugin/plugin.go +++ b/snapshots/btrfs/plugin/plugin.go @@ -23,9 +23,9 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots/btrfs" + "github.com/containerd/platforms" ) // Config represents configuration for the btrfs plugin. diff --git a/snapshots/devmapper/plugin/plugin.go b/snapshots/devmapper/plugin/plugin.go index 5b246602b0..8aceaf66e2 100644 --- a/snapshots/devmapper/plugin/plugin.go +++ b/snapshots/devmapper/plugin/plugin.go @@ -21,9 +21,9 @@ package plugin import ( "errors" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots/devmapper" + "github.com/containerd/platforms" ) func init() { diff --git a/snapshots/native/plugin/plugin.go b/snapshots/native/plugin/plugin.go index c9461426a5..b2a0c5d973 100644 --- a/snapshots/native/plugin/plugin.go +++ b/snapshots/native/plugin/plugin.go @@ -19,9 +19,9 @@ package plugin import ( "errors" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots/native" + "github.com/containerd/platforms" ) // Config represents configuration for the native plugin. diff --git a/snapshots/overlay/plugin/plugin.go b/snapshots/overlay/plugin/plugin.go index 2b97a67243..1381455541 100644 --- a/snapshots/overlay/plugin/plugin.go +++ b/snapshots/overlay/plugin/plugin.go @@ -21,9 +21,9 @@ package overlay import ( "errors" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots/overlay" + "github.com/containerd/platforms" ) // Config represents configuration for the overlay plugin. diff --git a/snapshots/windows/windows.go b/snapshots/windows/windows.go index f78adc4515..0df2180a9b 100644 --- a/snapshots/windows/windows.go +++ b/snapshots/windows/windows.go @@ -35,13 +35,13 @@ import ( "github.com/Microsoft/hcsshim" "github.com/Microsoft/hcsshim/pkg/ociwclayer" "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/storage" "github.com/containerd/continuity/fs" "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/vendor/github.com/containerd/platforms/.gitattributes b/vendor/github.com/containerd/platforms/.gitattributes new file mode 100644 index 0000000000..a0717e4b3b --- /dev/null +++ b/vendor/github.com/containerd/platforms/.gitattributes @@ -0,0 +1 @@ +*.go text eol=lf \ No newline at end of file diff --git a/vendor/github.com/containerd/platforms/.golangci.yml b/vendor/github.com/containerd/platforms/.golangci.yml new file mode 100644 index 0000000000..a695775df4 --- /dev/null +++ b/vendor/github.com/containerd/platforms/.golangci.yml @@ -0,0 +1,30 @@ +linters: + enable: + - exportloopref # Checks for pointers to enclosing loop variables + - gofmt + - goimports + - gosec + - ineffassign + - misspell + - nolintlint + - revive + - staticcheck + - tenv # Detects using os.Setenv instead of t.Setenv since Go 1.17 + - unconvert + - unused + - vet + - dupword # Checks for duplicate words in the source code + disable: + - errcheck + +run: + timeout: 5m + skip-dirs: + - api + - cluster + - design + - docs + - docs/man + - releases + - reports + - test # e2e scripts diff --git a/vendor/github.com/containerd/platforms/LICENSE b/vendor/github.com/containerd/platforms/LICENSE new file mode 100644 index 0000000000..584149b6ee --- /dev/null +++ b/vendor/github.com/containerd/platforms/LICENSE @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + 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 + + https://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. diff --git a/vendor/github.com/containerd/platforms/README.md b/vendor/github.com/containerd/platforms/README.md new file mode 100644 index 0000000000..2059de771c --- /dev/null +++ b/vendor/github.com/containerd/platforms/README.md @@ -0,0 +1,32 @@ +# platforms + +A Go package for formatting, normalizing and matching container platforms. + +This package is based on the Open Containers Image Spec definition of a [platform](https://github.com/opencontainers/image-spec/blob/main/specs-go/v1/descriptor.go#L52). + +## Platform Specifier + +While the OCI platform specifications provide a tool for components to +specify structured information, user input typically doesn't need the full +context and much can be inferred. To solve this problem, this package introduces +"specifiers". A specifier has the format +`||/[/]`. The user can provide either the +operating system or the architecture or both. + +An example of a common specifier is `linux/amd64`. If the host has a default +runtime that matches this, the user can simply provide the component that +matters. For example, if an image provides `amd64` and `arm64` support, the +operating system, `linux` can be inferred, so they only have to provide +`arm64` or `amd64`. Similar behavior is implemented for operating systems, +where the architecture may be known but a runtime may support images from +different operating systems. + +## Project details + +**platforms** is a containerd sub-project, licensed under the [Apache 2.0 license](./LICENSE). +As a containerd sub-project, you will find the: + * [Project governance](https://github.com/containerd/project/blob/main/GOVERNANCE.md), + * [Maintainers](https://github.com/containerd/project/blob/main/MAINTAINERS), + * and [Contributing guidelines](https://github.com/containerd/project/blob/main/CONTRIBUTING.md) + +information in our [`containerd/project`](https://github.com/containerd/project) repository. \ No newline at end of file diff --git a/platforms/compare.go b/vendor/github.com/containerd/platforms/compare.go similarity index 100% rename from platforms/compare.go rename to vendor/github.com/containerd/platforms/compare.go diff --git a/platforms/cpuinfo.go b/vendor/github.com/containerd/platforms/cpuinfo.go similarity index 100% rename from platforms/cpuinfo.go rename to vendor/github.com/containerd/platforms/cpuinfo.go diff --git a/platforms/cpuinfo_linux.go b/vendor/github.com/containerd/platforms/cpuinfo_linux.go similarity index 94% rename from platforms/cpuinfo_linux.go rename to vendor/github.com/containerd/platforms/cpuinfo_linux.go index e07aa99cc1..98c7001f93 100644 --- a/platforms/cpuinfo_linux.go +++ b/vendor/github.com/containerd/platforms/cpuinfo_linux.go @@ -19,12 +19,12 @@ package platforms import ( "bufio" "bytes" + "errors" "fmt" "os" "runtime" "strings" - "github.com/containerd/errdefs" "golang.org/x/sys/unix" ) @@ -70,7 +70,7 @@ func getCPUInfo(pattern string) (info string, err error) { return "", err } - return "", fmt.Errorf("getCPUInfo for pattern %s: %w", pattern, errdefs.ErrNotFound) + return "", fmt.Errorf("getCPUInfo for pattern %s: %w", pattern, errNotFound) } // getCPUVariantFromArch get CPU variant from arch through a system call @@ -83,7 +83,7 @@ func getCPUVariantFromArch(arch string) (string, error) { if arch == "aarch64" { variant = "8" } else if arch[0:4] == "armv" && len(arch) >= 5 { - //Valid arch format is in form of armvXx + // Valid arch format is in form of armvXx switch arch[3:5] { case "v8": variant = "8" @@ -101,7 +101,7 @@ func getCPUVariantFromArch(arch string) (string, error) { variant = "unknown" } } else { - return "", fmt.Errorf("getCPUVariantFromArch invalid arch: %s, %w", arch, errdefs.ErrInvalidArgument) + return "", fmt.Errorf("getCPUVariantFromArch invalid arch: %s, %w", arch, errInvalidArgument) } return variant, nil } @@ -112,11 +112,10 @@ func getCPUVariantFromArch(arch string) (string, error) { // This is to cover running ARM in emulated environment on x86 host as this field in /proc/cpuinfo // was not present. func getCPUVariant() (string, error) { - variant, err := getCPUInfo("Cpu architecture") if err != nil { - if errdefs.IsNotFound(err) { - //Let's try getting CPU variant from machine architecture + if errors.Is(err, errNotFound) { + // Let's try getting CPU variant from machine architecture arch, err := getMachineArch() if err != nil { return "", fmt.Errorf("failure getting machine architecture: %v", err) diff --git a/platforms/cpuinfo_other.go b/vendor/github.com/containerd/platforms/cpuinfo_other.go similarity index 95% rename from platforms/cpuinfo_other.go rename to vendor/github.com/containerd/platforms/cpuinfo_other.go index 8cbcbb24af..97a1fe8a3e 100644 --- a/platforms/cpuinfo_other.go +++ b/vendor/github.com/containerd/platforms/cpuinfo_other.go @@ -21,8 +21,6 @@ package platforms import ( "fmt" "runtime" - - "github.com/containerd/errdefs" ) func getCPUVariant() (string, error) { @@ -49,10 +47,8 @@ func getCPUVariant() (string, error) { default: variant = "unknown" } - } else { - return "", fmt.Errorf("getCPUVariant for OS %s: %v", runtime.GOOS, errdefs.ErrNotImplemented) - + return "", fmt.Errorf("getCPUVariant for OS %s: %v", runtime.GOOS, errNotImplemented) } return variant, nil diff --git a/platforms/database.go b/vendor/github.com/containerd/platforms/database.go similarity index 100% rename from platforms/database.go rename to vendor/github.com/containerd/platforms/database.go diff --git a/platforms/defaults.go b/vendor/github.com/containerd/platforms/defaults.go similarity index 81% rename from platforms/defaults.go rename to vendor/github.com/containerd/platforms/defaults.go index cfa3ff34a1..9d898d60e6 100644 --- a/platforms/defaults.go +++ b/vendor/github.com/containerd/platforms/defaults.go @@ -16,9 +16,11 @@ package platforms -// DefaultString returns the default string specifier for the platform. +// DefaultString returns the default string specifier for the platform, +// with [PR#6](https://github.com/containerd/platforms/pull/6) the result +// may now also include the OSVersion from the provided platform specification. func DefaultString() string { - return Format(DefaultSpec()) + return FormatAll(DefaultSpec()) } // DefaultStrict returns strict form of Default. diff --git a/platforms/defaults_darwin.go b/vendor/github.com/containerd/platforms/defaults_darwin.go similarity index 100% rename from platforms/defaults_darwin.go rename to vendor/github.com/containerd/platforms/defaults_darwin.go diff --git a/platforms/defaults_freebsd.go b/vendor/github.com/containerd/platforms/defaults_freebsd.go similarity index 100% rename from platforms/defaults_freebsd.go rename to vendor/github.com/containerd/platforms/defaults_freebsd.go diff --git a/platforms/defaults_unix.go b/vendor/github.com/containerd/platforms/defaults_unix.go similarity index 100% rename from platforms/defaults_unix.go rename to vendor/github.com/containerd/platforms/defaults_unix.go diff --git a/platforms/defaults_windows.go b/vendor/github.com/containerd/platforms/defaults_windows.go similarity index 100% rename from platforms/defaults_windows.go rename to vendor/github.com/containerd/platforms/defaults_windows.go diff --git a/platforms/defaults_unix_test.go b/vendor/github.com/containerd/platforms/errors.go similarity index 53% rename from platforms/defaults_unix_test.go rename to vendor/github.com/containerd/platforms/errors.go index 8aba958772..5ad721e779 100644 --- a/platforms/defaults_unix_test.go +++ b/vendor/github.com/containerd/platforms/errors.go @@ -1,5 +1,3 @@ -//go:build !windows - /* Copyright The containerd Authors. @@ -18,27 +16,15 @@ package platforms -import ( - "reflect" - "runtime" - "testing" +import "errors" - specs "github.com/opencontainers/image-spec/specs-go/v1" +// These errors mirror the errors defined in [github.com/containerd/containerd/errdefs], +// however, they are not exported as they are not expected to be used as sentinel +// errors by consumers of this package. +// +//nolint:unused // not all errors are used on all platforms. +var ( + errNotFound = errors.New("not found") + errInvalidArgument = errors.New("invalid argument") + errNotImplemented = errors.New("not implemented") ) - -func TestDefault(t *testing.T) { - expected := specs.Platform{ - OS: runtime.GOOS, - Architecture: runtime.GOARCH, - Variant: cpuVariant(), - } - p := DefaultSpec() - if !reflect.DeepEqual(p, expected) { - t.Fatalf("default platform not as expected: %#v != %#v", p, expected) - } - - s := DefaultString() - if s != Format(p) { - t.Fatalf("default specifier should match formatted default spec: %v != %v", s, p) - } -} diff --git a/platforms/platforms.go b/vendor/github.com/containerd/platforms/platforms.go similarity index 74% rename from platforms/platforms.go rename to vendor/github.com/containerd/platforms/platforms.go index 44bc24a5c6..1bbbdb91db 100644 --- a/platforms/platforms.go +++ b/vendor/github.com/containerd/platforms/platforms.go @@ -102,6 +102,9 @@ // unless it is explicitly provided. This is treated as equivalent to armhf. A // previous architecture, armel, will be normalized to arm/v6. // +// Similarly, the most common arm64 version v8, and most common amd64 version v1 +// are represented without the variant. +// // While these normalizations are provided, their support on arm platforms has // not yet been fully implemented and tested. package platforms @@ -115,14 +118,15 @@ import ( "strings" specs "github.com/opencontainers/image-spec/specs-go/v1" - - "github.com/containerd/errdefs" ) var ( - specifierRe = regexp.MustCompile(`^[A-Za-z0-9_-]+$`) + specifierRe = regexp.MustCompile(`^[A-Za-z0-9_-]+$`) + osAndVersionRe = regexp.MustCompile(`^([A-Za-z0-9_-]+)(?:\(([A-Za-z0-9_.-]*)\))?$`) ) +const osAndVersionFormat = "%s(%s)" + // Platform is a type alias for convenience, so there is no need to import image-spec package everywhere. type Platform = specs.Platform @@ -155,40 +159,68 @@ func (m *matcher) Match(platform specs.Platform) bool { } func (m *matcher) String() string { - return Format(m.Platform) + return FormatAll(m.Platform) +} + +// ParseAll parses a list of platform specifiers into a list of platform. +func ParseAll(specifiers []string) ([]specs.Platform, error) { + platforms := make([]specs.Platform, len(specifiers)) + for i, s := range specifiers { + p, err := Parse(s) + if err != nil { + return nil, fmt.Errorf("invalid platform %s: %w", s, err) + } + platforms[i] = p + } + return platforms, nil } // Parse parses the platform specifier syntax into a platform declaration. // -// Platform specifiers are in the format `||/[/]`. +// Platform specifiers are in the format `[()]||[()]/[/]`. // The minimum required information for a platform specifier is the operating -// system or architecture. If there is only a single string (no slashes), the +// system or architecture. The OSVersion can be part of the OS like `windows(10.0.17763)` +// When an OSVersion is specified, then specs.Platform.OSVersion is populated with that value, +// and an empty string otherwise. +// If there is only a single string (no slashes), the // value will be matched against the known set of operating systems, then fall // back to the known set of architectures. The missing component will be // inferred based on the local environment. func Parse(specifier string) (specs.Platform, error) { if strings.Contains(specifier, "*") { // TODO(stevvooe): need to work out exact wildcard handling - return specs.Platform{}, fmt.Errorf("%q: wildcards not yet supported: %w", specifier, errdefs.ErrInvalidArgument) + return specs.Platform{}, fmt.Errorf("%q: wildcards not yet supported: %w", specifier, errInvalidArgument) } - parts := strings.Split(specifier, "/") + // Limit to 4 elements to prevent unbounded split + parts := strings.SplitN(specifier, "/", 4) - for _, part := range parts { - if !specifierRe.MatchString(part) { - return specs.Platform{}, fmt.Errorf("%q is an invalid component of %q: platform specifier component must match %q: %w", part, specifier, specifierRe.String(), errdefs.ErrInvalidArgument) + var p specs.Platform + for i, part := range parts { + if i == 0 { + // First element is [()] + osVer := osAndVersionRe.FindStringSubmatch(part) + if osVer == nil { + return specs.Platform{}, fmt.Errorf("%q is an invalid OS component of %q: OSAndVersion specifier component must match %q: %w", part, specifier, osAndVersionRe.String(), errInvalidArgument) + } + + p.OS = normalizeOS(osVer[1]) + p.OSVersion = osVer[2] + } else { + if !specifierRe.MatchString(part) { + return specs.Platform{}, fmt.Errorf("%q is an invalid component of %q: platform specifier component must match %q: %w", part, specifier, specifierRe.String(), errInvalidArgument) + } } } - var p specs.Platform switch len(parts) { case 1: - // in this case, we will test that the value might be an OS, then look - // it up. If it is not known, we'll treat it as an architecture. Since + // in this case, we will test that the value might be an OS (with or + // without the optional OSVersion specified) and look it up. + // If it is not known, we'll treat it as an architecture. Since // we have very little information about the platform here, we are // going to be a little more strict if we don't know about the argument // value. - p.OS = normalizeOS(parts[0]) if isKnownOS(p.OS) { // picks a default architecture p.Architecture = runtime.GOARCH @@ -196,10 +228,6 @@ func Parse(specifier string) (specs.Platform, error) { p.Variant = cpuVariant() } - if p.OS == "windows" { - p.OSVersion = GetWindowsOsVersion() - } - return p, nil } @@ -212,37 +240,27 @@ func Parse(specifier string) (specs.Platform, error) { return p, nil } - return specs.Platform{}, fmt.Errorf("%q: unknown operating system or architecture: %w", specifier, errdefs.ErrInvalidArgument) + return specs.Platform{}, fmt.Errorf("%q: unknown operating system or architecture: %w", specifier, errInvalidArgument) case 2: - // In this case, we treat as a regular os/arch pair. We don't care + // In this case, we treat as a regular OS[(OSVersion)]/arch pair. We don't care // about whether or not we know of the platform. - p.OS = normalizeOS(parts[0]) p.Architecture, p.Variant = normalizeArch(parts[1], "") if p.Architecture == "arm" && p.Variant == "v7" { p.Variant = "" } - if p.OS == "windows" { - p.OSVersion = GetWindowsOsVersion() - } - return p, nil case 3: // we have a fully specified variant, this is rare - p.OS = normalizeOS(parts[0]) p.Architecture, p.Variant = normalizeArch(parts[1], parts[2]) if p.Architecture == "arm64" && p.Variant == "" { p.Variant = "v8" } - if p.OS == "windows" { - p.OSVersion = GetWindowsOsVersion() - } - return p, nil } - return specs.Platform{}, fmt.Errorf("%q: cannot parse platform specifier: %w", specifier, errdefs.ErrInvalidArgument) + return specs.Platform{}, fmt.Errorf("%q: cannot parse platform specifier: %w", specifier, errInvalidArgument) } // MustParse is like Parses but panics if the specifier cannot be parsed. @@ -264,6 +282,20 @@ func Format(platform specs.Platform) string { return path.Join(platform.OS, platform.Architecture, platform.Variant) } +// FormatAll returns a string specifier that also includes the OSVersion from the +// provided platform specification. +func FormatAll(platform specs.Platform) string { + if platform.OS == "" { + return "unknown" + } + + if platform.OSVersion != "" { + OSAndVersion := fmt.Sprintf(osAndVersionFormat, platform.OS, platform.OSVersion) + return path.Join(OSAndVersion, platform.Architecture, platform.Variant) + } + return path.Join(platform.OS, platform.Architecture, platform.Variant) +} + // Normalize validates and translate the platform to the canonical value. // // For example, if "Aarch64" is encountered, we change it to "arm64" or if diff --git a/platforms/platforms_other.go b/vendor/github.com/containerd/platforms/platforms_other.go similarity index 94% rename from platforms/platforms_other.go rename to vendor/github.com/containerd/platforms/platforms_other.go index 59beeb3d1d..03f4dcd998 100644 --- a/platforms/platforms_other.go +++ b/vendor/github.com/containerd/platforms/platforms_other.go @@ -28,7 +28,3 @@ func newDefaultMatcher(platform specs.Platform) Matcher { Platform: Normalize(platform), } } - -func GetWindowsOsVersion() string { - return "" -} diff --git a/platforms/platforms_windows.go b/vendor/github.com/containerd/platforms/platforms_windows.go similarity index 85% rename from platforms/platforms_windows.go rename to vendor/github.com/containerd/platforms/platforms_windows.go index 733d18ddea..950e2a2ddb 100644 --- a/platforms/platforms_windows.go +++ b/vendor/github.com/containerd/platforms/platforms_windows.go @@ -17,10 +17,7 @@ package platforms import ( - "fmt" - specs "github.com/opencontainers/image-spec/specs-go/v1" - "golang.org/x/sys/windows" ) // NewMatcher returns a Windows matcher that will match on osVersionPrefix if @@ -35,8 +32,3 @@ func newDefaultMatcher(platform specs.Platform) Matcher { }, } } - -func GetWindowsOsVersion() string { - major, minor, build := windows.RtlGetNtVersionNumbers() - return fmt.Sprintf("%d.%d.%d", major, minor, build) -} diff --git a/vendor/modules.txt b/vendor/modules.txt index d3fc4d1b54..b17b8e0a75 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -144,6 +144,9 @@ github.com/containerd/nri/pkg/net/multiplex github.com/containerd/nri/pkg/runtime-tools/generate github.com/containerd/nri/pkg/stub github.com/containerd/nri/types/v1 +# github.com/containerd/platforms v0.2.0 +## explicit; go 1.20 +github.com/containerd/platforms # github.com/containerd/ttrpc v1.2.4 ## explicit; go 1.19 github.com/containerd/ttrpc