From b61988670c7c951a0bf4f11f6ea9d926f3e79d35 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Sat, 11 Feb 2023 23:30:32 +0900 Subject: [PATCH] go.mod: github.com/containerd/typeurl/v2 v2.1.0 Changes: https://github.com/containerd/typeurl/compare/7f6e6d160d67...v2.1.0 Signed-off-by: Akihiro Suda --- api/events/container_fieldpath.pb.go | 4 +- .../ttrpc/events/v1/events_fieldpath.pb.go | 4 +- client.go | 2 +- cmd/ctr/commands/cni.go | 2 +- cmd/ctr/commands/containers/containers.go | 2 +- cmd/ctr/commands/events/events.go | 2 +- cmd/ctr/commands/shim/shim.go | 2 +- cmd/ctr/commands/tasks/kill.go | 2 +- cmd/ctr/commands/tasks/metrics.go | 2 +- cmd/ctr/commands/tasks/ps.go | 2 +- cmd/protoc-gen-go-fieldpath/generator.go | 2 +- container.go | 2 +- container_opts.go | 2 +- containers/containers.go | 2 +- containerstore.go | 2 +- diff/diff.go | 2 +- diff/stream.go | 2 +- diff/stream_unix.go | 2 +- diff/stream_windows.go | 2 +- docs/SECURITY_AUDIT.pdf | Bin 151169 -> 151172 bytes events.go | 2 +- events/events.go | 2 +- events/exchange/exchange.go | 2 +- events/exchange/exchange_test.go | 2 +- go.mod | 3 +- go.sum | 5 +- integration/client/container_test.go | 2 +- integration/client/go.mod | 2 +- integration/client/go.sum | 4 +- integration/client/restart_monitor_test.go | 2 +- integration/sandbox_run_rollback_test.go | 2 +- metadata/boltutil/helpers.go | 2 +- metadata/compare_test.go | 2 +- metadata/containers.go | 2 +- metadata/containers_test.go | 2 +- metadata/sandbox.go | 2 +- metadata/sandbox_test.go | 2 +- metrics/cgroups/v1/metrics.go | 2 +- metrics/cgroups/v2/metrics.go | 2 +- pkg/cri/sbserver/container_create.go | 2 +- .../sbserver/container_stats_list_linux.go | 2 +- .../sbserver/container_stats_list_windows.go | 2 +- .../sbserver/container_update_resources.go | 2 +- pkg/cri/sbserver/events.go | 2 +- pkg/cri/sbserver/events_test.go | 2 +- pkg/cri/sbserver/helpers.go | 2 +- pkg/cri/sbserver/helpers_test.go | 2 +- pkg/cri/sbserver/podsandbox/sandbox_run.go | 2 +- .../sbserver/podsandbox/sandbox_run_test.go | 2 +- pkg/cri/sbserver/podsandbox/sandbox_status.go | 2 +- pkg/cri/sbserver/restart.go | 2 +- pkg/cri/sbserver/sandbox_run.go | 2 +- pkg/cri/server/container_create.go | 2 +- pkg/cri/server/container_stats_list_linux.go | 2 +- .../server/container_stats_list_windows.go | 2 +- pkg/cri/server/container_update_resources.go | 2 +- pkg/cri/server/events.go | 2 +- pkg/cri/server/events_test.go | 2 +- pkg/cri/server/helpers.go | 2 +- pkg/cri/server/helpers_test.go | 2 +- pkg/cri/server/nri-api.go | 2 +- pkg/cri/server/restart.go | 2 +- pkg/cri/server/sandbox_run.go | 2 +- pkg/cri/server/sandbox_run_test.go | 2 +- pkg/streaming/streaming.go | 2 +- pkg/transfer/archive/exporter.go | 2 +- pkg/transfer/archive/importer.go | 2 +- pkg/transfer/image/imagestore.go | 2 +- pkg/transfer/image/registry.go | 2 +- pkg/transfer/local/transfer.go | 2 +- pkg/transfer/plugins/plugins.go | 2 +- pkg/transfer/proxy/transfer.go | 2 +- pkg/transfer/streaming/stream.go | 2 +- pkg/transfer/streaming/stream_test.go | 2 +- pkg/transfer/streaming/writer.go | 2 +- protobuf/any.go | 2 +- runtime/runtime.go | 2 +- runtime/typeurl.go | 2 +- runtime/v1/linux/runtime.go | 2 +- runtime/v1/shim/service.go | 2 +- runtime/v2/bundle.go | 2 +- runtime/v2/bundle_linux_test.go | 2 +- runtime/v2/runc/container.go | 2 +- runtime/v2/runc/task/service.go | 2 +- runtime/v2/runc/v1/service.go | 2 +- runtime/v2/shim/util.go | 2 +- sandbox.go | 2 +- sandbox/controller.go | 2 +- sandbox/helpers.go | 2 +- sandbox/store.go | 2 +- sandbox/store_test.go | 2 +- services/containers/helpers.go | 2 +- services/diff/local.go | 2 +- services/streaming/service.go | 2 +- services/tasks/local.go | 2 +- services/transfer/service.go | 2 +- task.go | 2 +- transfer.go | 2 +- .../github.com/containerd/typeurl/README.md | 2 +- vendor/github.com/containerd/typeurl/types.go | 97 ++----- .../containerd/typeurl/v2/.gitignore | 2 + .../github.com/containerd/typeurl/v2/LICENSE | 191 ++++++++++++ .../containerd/typeurl/v2/README.md | 20 ++ .../github.com/containerd/typeurl/v2/doc.go | 83 ++++++ .../github.com/containerd/typeurl/v2/types.go | 273 ++++++++++++++++++ vendor/modules.txt | 5 +- 106 files changed, 702 insertions(+), 175 deletions(-) create mode 100644 vendor/github.com/containerd/typeurl/v2/.gitignore create mode 100644 vendor/github.com/containerd/typeurl/v2/LICENSE create mode 100644 vendor/github.com/containerd/typeurl/v2/README.md create mode 100644 vendor/github.com/containerd/typeurl/v2/doc.go create mode 100644 vendor/github.com/containerd/typeurl/v2/types.go diff --git a/api/events/container_fieldpath.pb.go b/api/events/container_fieldpath.pb.go index 0a9e8c2625cb..c23b07762e3f 100644 --- a/api/events/container_fieldpath.pb.go +++ b/api/events/container_fieldpath.pb.go @@ -3,7 +3,7 @@ package events import ( - typeurl "github.com/containerd/typeurl" + v2 "github.com/containerd/typeurl/v2" strings "strings" ) @@ -43,7 +43,7 @@ func (m *ContainerCreate_Runtime) Field(fieldpath []string) (string, bool) { case "name": return string(m.Name), len(m.Name) > 0 case "options": - decoded, err := typeurl.UnmarshalAny(m.Options) + decoded, err := v2.UnmarshalAny(m.Options) if err != nil { return "", false } diff --git a/api/services/ttrpc/events/v1/events_fieldpath.pb.go b/api/services/ttrpc/events/v1/events_fieldpath.pb.go index 9321e37ab66f..ad48127be919 100644 --- a/api/services/ttrpc/events/v1/events_fieldpath.pb.go +++ b/api/services/ttrpc/events/v1/events_fieldpath.pb.go @@ -3,7 +3,7 @@ package events import ( - typeurl "github.com/containerd/typeurl" + v2 "github.com/containerd/typeurl/v2" ) // Field returns the value for the given fieldpath as a string, if defined. @@ -41,7 +41,7 @@ func (m *Envelope) Field(fieldpath []string) (string, bool) { case "topic": return string(m.Topic), len(m.Topic) > 0 case "event": - decoded, err := typeurl.UnmarshalAny(m.Event) + decoded, err := v2.UnmarshalAny(m.Event) if err != nil { return "", false } diff --git a/client.go b/client.go index 4133476b167f..a62217b96141 100644 --- a/client.go +++ b/client.go @@ -61,7 +61,7 @@ import ( "github.com/containerd/containerd/services/introspection" "github.com/containerd/containerd/snapshots" snproxy "github.com/containerd/containerd/snapshots/proxy" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/opencontainers/runtime-spec/specs-go" "golang.org/x/sync/semaphore" diff --git a/cmd/ctr/commands/cni.go b/cmd/ctr/commands/cni.go index b2ef39c98759..4c15306a671a 100644 --- a/cmd/ctr/commands/cni.go +++ b/cmd/ctr/commands/cni.go @@ -22,7 +22,7 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/namespaces" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) func init() { diff --git a/cmd/ctr/commands/containers/containers.go b/cmd/ctr/commands/containers/containers.go index bb1ef51e7ff4..4acd089e6ffa 100644 --- a/cmd/ctr/commands/containers/containers.go +++ b/cmd/ctr/commands/containers/containers.go @@ -30,7 +30,7 @@ import ( "github.com/containerd/containerd/containers" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/log" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/urfave/cli" ) diff --git a/cmd/ctr/commands/events/events.go b/cmd/ctr/commands/events/events.go index 709b1a66fdcb..761d43a36807 100644 --- a/cmd/ctr/commands/events/events.go +++ b/cmd/ctr/commands/events/events.go @@ -23,7 +23,7 @@ import ( "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/events" "github.com/containerd/containerd/log" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/urfave/cli" // Register grpc event types diff --git a/cmd/ctr/commands/shim/shim.go b/cmd/ctr/commands/shim/shim.go index cb439d6dd7a4..dfbb1f255a7d 100644 --- a/cmd/ctr/commands/shim/shim.go +++ b/cmd/ctr/commands/shim/shim.go @@ -34,7 +34,7 @@ import ( ptypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/runtime/v2/shim" "github.com/containerd/ttrpc" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "github.com/urfave/cli" diff --git a/cmd/ctr/commands/tasks/kill.go b/cmd/ctr/commands/tasks/kill.go index f996115d2167..27072609d43b 100644 --- a/cmd/ctr/commands/tasks/kill.go +++ b/cmd/ctr/commands/tasks/kill.go @@ -24,7 +24,7 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/cmd/ctr/commands" gocni "github.com/containerd/go-cni" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/moby/sys/signal" "github.com/sirupsen/logrus" "github.com/urfave/cli" diff --git a/cmd/ctr/commands/tasks/metrics.go b/cmd/ctr/commands/tasks/metrics.go index b99c31629158..aa43b5641c0f 100644 --- a/cmd/ctr/commands/tasks/metrics.go +++ b/cmd/ctr/commands/tasks/metrics.go @@ -28,7 +28,7 @@ import ( v2 "github.com/containerd/cgroups/v3/cgroup2/stats" "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/protobuf/proto" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/urfave/cli" ) diff --git a/cmd/ctr/commands/tasks/ps.go b/cmd/ctr/commands/tasks/ps.go index cb444b3da57a..78da3cb84ee9 100644 --- a/cmd/ctr/commands/tasks/ps.go +++ b/cmd/ctr/commands/tasks/ps.go @@ -23,7 +23,7 @@ import ( "text/tabwriter" "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/urfave/cli" ) diff --git a/cmd/protoc-gen-go-fieldpath/generator.go b/cmd/protoc-gen-go-fieldpath/generator.go index 73f1c6fedf52..b651f1b06579 100644 --- a/cmd/protoc-gen-go-fieldpath/generator.go +++ b/cmd/protoc-gen-go-fieldpath/generator.go @@ -82,7 +82,7 @@ func (gen *generator) genFieldMethod(m *protogen.Message) { p.P("return value, ok") case isAnyField(f): typeurlUnmarshalAny := gen.out.QualifiedGoIdent(protogen.GoIdent{ - GoImportPath: "github.com/containerd/typeurl", + GoImportPath: "github.com/containerd/typeurl/v2", GoName: "UnmarshalAny", }) diff --git a/container.go b/container.go index ded5e30eea9b..2890bfdc4344 100644 --- a/container.go +++ b/container.go @@ -35,7 +35,7 @@ import ( "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/containerd/fifo" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ver "github.com/opencontainers/image-spec/specs-go" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/opencontainers/selinux/go-selinux/label" diff --git a/container_opts.go b/container_opts.go index 0719ed293da7..4a937032f566 100644 --- a/container_opts.go +++ b/container_opts.go @@ -30,7 +30,7 @@ import ( "github.com/containerd/containerd/oci" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/snapshots" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/opencontainers/image-spec/identity" v1 "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/containers/containers.go b/containers/containers.go index 9aa0ba0d41f3..49f389133649 100644 --- a/containers/containers.go +++ b/containers/containers.go @@ -20,7 +20,7 @@ import ( "context" "time" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) // Container represents the set of data pinned by a container. Unless otherwise diff --git a/containerstore.go b/containerstore.go index e3796ad0a9a0..331a6f41de04 100644 --- a/containerstore.go +++ b/containerstore.go @@ -26,7 +26,7 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) diff --git a/diff/diff.go b/diff/diff.go index fdedae244361..56c7e669403d 100644 --- a/diff/diff.go +++ b/diff/diff.go @@ -22,7 +22,7 @@ import ( "time" "github.com/containerd/containerd/mount" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/diff/stream.go b/diff/stream.go index 58cf23674f23..b80e6d1a5c7f 100644 --- a/diff/stream.go +++ b/diff/stream.go @@ -24,7 +24,7 @@ import ( "github.com/containerd/containerd/archive/compression" "github.com/containerd/containerd/images" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/diff/stream_unix.go b/diff/stream_unix.go index dbc11a54f571..82fc31b402d3 100644 --- a/diff/stream_unix.go +++ b/diff/stream_unix.go @@ -29,7 +29,7 @@ import ( "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/protobuf/proto" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" exec "golang.org/x/sys/execabs" ) diff --git a/diff/stream_windows.go b/diff/stream_windows.go index a5ae19728aee..e6026f4e98ad 100644 --- a/diff/stream_windows.go +++ b/diff/stream_windows.go @@ -29,7 +29,7 @@ import ( winio "github.com/Microsoft/go-winio" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/protobuf/proto" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/sirupsen/logrus" exec "golang.org/x/sys/execabs" ) diff --git a/docs/SECURITY_AUDIT.pdf b/docs/SECURITY_AUDIT.pdf index 4ff7a8f130ef807eb89fbd658f0231428f51751c..7da848450e674d0360a54ecebd3d5de062729b17 100644 GIT binary patch delta 23 fcmZpi%h@uQv!R7?3)4qSX8kgw?H?_fCWrt4YVrt} delta 19 bcmZpf%h@=Wv!R7?3)4r-?O!aJCWrt4Pg@7U diff --git a/events.go b/events.go index 75d46cedbef1..32d2dfc3158e 100644 --- a/events.go +++ b/events.go @@ -23,7 +23,7 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/protobuf" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) // EventService handles the publish, forward and subscribe of events. diff --git a/events/events.go b/events/events.go index 8af0ec03a483..ff5642301f40 100644 --- a/events/events.go +++ b/events/events.go @@ -20,7 +20,7 @@ import ( "context" "time" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) // Envelope provides the packaging for an event. diff --git a/events/exchange/exchange.go b/events/exchange/exchange.go index 7f085dc91774..e94da2adfe58 100644 --- a/events/exchange/exchange.go +++ b/events/exchange/exchange.go @@ -28,7 +28,7 @@ import ( "github.com/containerd/containerd/identifiers" "github.com/containerd/containerd/log" "github.com/containerd/containerd/namespaces" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" goevents "github.com/docker/go-events" "github.com/sirupsen/logrus" ) diff --git a/events/exchange/exchange_test.go b/events/exchange/exchange_test.go index 6fb15dc97c15..422586cf3083 100644 --- a/events/exchange/exchange_test.go +++ b/events/exchange/exchange_test.go @@ -27,7 +27,7 @@ import ( "github.com/containerd/containerd/events" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/protobuf" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/google/go-cmp/cmp" ) diff --git a/go.mod b/go.mod index fd77855755a7..7f6ab9f8f36b 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/containerd/imgcrypt v1.1.5-0.20220421044638-8ba028dca028 github.com/containerd/nri v0.2.1-0.20230131001841-b3cabdec0657 github.com/containerd/ttrpc v1.1.1-0.20230127163717-32fab2374638 - github.com/containerd/typeurl v1.0.3-0.20220422153119-7f6e6d160d67 + github.com/containerd/typeurl/v2 v2.1.0 github.com/containerd/zfs v1.0.0 github.com/containernetworking/cni v1.1.2 github.com/containernetworking/plugins v1.2.0 @@ -89,6 +89,7 @@ require ( github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cilium/ebpf v0.9.1 // indirect github.com/containerd/cgroups v1.1.0 // indirect + github.com/containerd/typeurl v1.0.2 // indirect github.com/containers/ocicrypt v1.1.3 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/cyphar/filepath-securejoin v0.2.3 // indirect diff --git a/go.sum b/go.sum index f3b501107c56..8cb0374f2ec6 100644 --- a/go.sum +++ b/go.sum @@ -277,9 +277,10 @@ github.com/containerd/ttrpc v1.1.1-0.20230127163717-32fab2374638/go.mod h1:YYyNV github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc= github.com/containerd/typeurl v0.0.0-20190911142611-5eb25027c9fd/go.mod h1:GeKYzf2pQcqv7tJ0AoCuuhtnqhva5LNU3U+OyKxxJpk= github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg= +github.com/containerd/typeurl v1.0.2 h1:Chlt8zIieDbzQFzXzAeBEF92KhExuE4p9p92/QmY7aY= github.com/containerd/typeurl v1.0.2/go.mod h1:9trJWW2sRlGub4wZJRTW83VtbOLS6hwcDZXTn6oPz9s= -github.com/containerd/typeurl v1.0.3-0.20220422153119-7f6e6d160d67 h1:rQvjv7gRi6Ki/NS/U9oLZFhqyk4dh/GH2M3o/4BRkMM= -github.com/containerd/typeurl v1.0.3-0.20220422153119-7f6e6d160d67/go.mod h1:HDkcKOXRnX6yKnXv3P0QrogFi0DoiauK/LpQi961f0A= +github.com/containerd/typeurl/v2 v2.1.0 h1:yNAhJvbNEANt7ck48IlEGOxP7YAp6LLpGn5jZACDNIE= +github.com/containerd/typeurl/v2 v2.1.0/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= github.com/containerd/zfs v0.0.0-20200918131355-0a33824f23a2/go.mod h1:8IgZOBdv8fAgXddBT4dBXJPtxyRsejFIpXoklgxgEjw= github.com/containerd/zfs v0.0.0-20210301145711-11e8f1707f62/go.mod h1:A9zfAbMlQwE+/is6hi0Xw8ktpL+6glmqZYtevJgaB8Y= github.com/containerd/zfs v0.0.0-20210315114300-dde8f0fda960/go.mod h1:m+m51S1DvAP6r3FcmYCp54bQ34pyOwTieQDNRIRHsFY= diff --git a/integration/client/container_test.go b/integration/client/container_test.go index 2cce96e4efda..6af3fd9b8331 100644 --- a/integration/client/container_test.go +++ b/integration/client/container_test.go @@ -44,7 +44,7 @@ import ( _ "github.com/containerd/containerd/runtime" "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/containerd/go-runc" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/require" exec "golang.org/x/sys/execabs" diff --git a/integration/client/go.mod b/integration/client/go.mod index f260fe5cb6cd..8546a63c7448 100644 --- a/integration/client/go.mod +++ b/integration/client/go.mod @@ -10,7 +10,7 @@ require ( github.com/containerd/containerd v1.7.0-beta.0 // see replace; the actual version of containerd is replaced with the code at the root of this repository github.com/containerd/go-runc v1.0.0 github.com/containerd/ttrpc v1.1.1-0.20230127163717-32fab2374638 - github.com/containerd/typeurl v1.0.3-0.20220422153119-7f6e6d160d67 + github.com/containerd/typeurl/v2 v2.1.0 github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb diff --git a/integration/client/go.sum b/integration/client/go.sum index 9db7f67722b5..f98708e4ebfc 100644 --- a/integration/client/go.sum +++ b/integration/client/go.sum @@ -530,8 +530,8 @@ github.com/containerd/ttrpc v1.1.1-0.20230127163717-32fab2374638 h1:8eVDsirmav+3 github.com/containerd/ttrpc v1.1.1-0.20230127163717-32fab2374638/go.mod h1:YYyNVhZrTMiaf51Vj6WhAJqJw+vl/nzABhj8pWrzle4= github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg= github.com/containerd/typeurl v1.0.2/go.mod h1:9trJWW2sRlGub4wZJRTW83VtbOLS6hwcDZXTn6oPz9s= -github.com/containerd/typeurl v1.0.3-0.20220422153119-7f6e6d160d67 h1:rQvjv7gRi6Ki/NS/U9oLZFhqyk4dh/GH2M3o/4BRkMM= -github.com/containerd/typeurl v1.0.3-0.20220422153119-7f6e6d160d67/go.mod h1:HDkcKOXRnX6yKnXv3P0QrogFi0DoiauK/LpQi961f0A= +github.com/containerd/typeurl/v2 v2.1.0 h1:yNAhJvbNEANt7ck48IlEGOxP7YAp6LLpGn5jZACDNIE= +github.com/containerd/typeurl/v2 v2.1.0/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= github.com/containerd/zfs v1.0.0/go.mod h1:m+m51S1DvAP6r3FcmYCp54bQ34pyOwTieQDNRIRHsFY= github.com/containernetworking/cni v1.0.1/go.mod h1:AKuhXbN5EzmD4yTNtfSsX3tPcmtrBI6QcRV0NiNt15Y= github.com/containernetworking/cni v1.1.1/go.mod h1:sDpYKmGVENF3s6uvMvGgldDWeG8dMxakj/u+i9ht9vw= diff --git a/integration/client/restart_monitor_test.go b/integration/client/restart_monitor_test.go index 0681f6fc8c23..e7d0025e6d59 100644 --- a/integration/client/restart_monitor_test.go +++ b/integration/client/restart_monitor_test.go @@ -36,7 +36,7 @@ import ( "github.com/containerd/containerd/pkg/testutil" "github.com/containerd/containerd/runtime/restart" srvconfig "github.com/containerd/containerd/services/server/config" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" exec "golang.org/x/sys/execabs" ) diff --git a/integration/sandbox_run_rollback_test.go b/integration/sandbox_run_rollback_test.go index d581c915956f..c84f10ca7af0 100644 --- a/integration/sandbox_run_rollback_test.go +++ b/integration/sandbox_run_rollback_test.go @@ -39,7 +39,7 @@ import ( "github.com/containerd/containerd/pkg/cri/sbserver/podsandbox" "github.com/containerd/containerd/pkg/cri/store/sandbox" "github.com/containerd/containerd/pkg/failpoint" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) const ( diff --git a/metadata/boltutil/helpers.go b/metadata/boltutil/helpers.go index c0d3ef4021ae..8f8df3361514 100644 --- a/metadata/boltutil/helpers.go +++ b/metadata/boltutil/helpers.go @@ -23,7 +23,7 @@ import ( "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/protobuf/proto" "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" bolt "go.etcd.io/bbolt" ) diff --git a/metadata/compare_test.go b/metadata/compare_test.go index 177958a83201..726170726993 100644 --- a/metadata/compare_test.go +++ b/metadata/compare_test.go @@ -21,7 +21,7 @@ import ( "reflect" "time" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/google/go-cmp/cmp" ) diff --git a/metadata/containers.go b/metadata/containers.go index 36ef0c4ae886..d97d9c6cd1ac 100644 --- a/metadata/containers.go +++ b/metadata/containers.go @@ -32,7 +32,7 @@ import ( "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/protobuf/proto" "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" bolt "go.etcd.io/bbolt" ) diff --git a/metadata/containers_test.go b/metadata/containers_test.go index 8f8a7d8ec39a..efcedae1ea34 100644 --- a/metadata/containers_test.go +++ b/metadata/containers_test.go @@ -32,7 +32,7 @@ import ( "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/google/go-cmp/cmp" "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/assert" diff --git a/metadata/sandbox.go b/metadata/sandbox.go index cb9dc548b959..5766647d33e3 100644 --- a/metadata/sandbox.go +++ b/metadata/sandbox.go @@ -29,7 +29,7 @@ import ( "github.com/containerd/containerd/metadata/boltutil" "github.com/containerd/containerd/namespaces" api "github.com/containerd/containerd/sandbox" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "go.etcd.io/bbolt" ) diff --git a/metadata/sandbox_test.go b/metadata/sandbox_test.go index f822bd35e91f..711fb0c13abf 100644 --- a/metadata/sandbox_test.go +++ b/metadata/sandbox_test.go @@ -22,7 +22,7 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/protobuf/types" api "github.com/containerd/containerd/sandbox" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/google/go-cmp/cmp" ) diff --git a/metrics/cgroups/v1/metrics.go b/metrics/cgroups/v1/metrics.go index 983f781296d0..749dba1175c4 100644 --- a/metrics/cgroups/v1/metrics.go +++ b/metrics/cgroups/v1/metrics.go @@ -30,7 +30,7 @@ import ( v1 "github.com/containerd/containerd/metrics/types/v1" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/timeout" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/docker/go-metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/metrics/cgroups/v2/metrics.go b/metrics/cgroups/v2/metrics.go index ece4e1057e48..00f5f40bc7bd 100644 --- a/metrics/cgroups/v2/metrics.go +++ b/metrics/cgroups/v2/metrics.go @@ -29,7 +29,7 @@ import ( v2 "github.com/containerd/containerd/metrics/types/v2" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/timeout" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/docker/go-metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/pkg/cri/sbserver/container_create.go b/pkg/cri/sbserver/container_create.go index 16e8d9cc71c1..0109ccd31ccc 100644 --- a/pkg/cri/sbserver/container_create.go +++ b/pkg/cri/sbserver/container_create.go @@ -24,7 +24,7 @@ import ( "strconv" "time" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/davecgh/go-spew/spew" imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtimespec "github.com/opencontainers/runtime-spec/specs-go" diff --git a/pkg/cri/sbserver/container_stats_list_linux.go b/pkg/cri/sbserver/container_stats_list_linux.go index bdf4d1d546c5..a81a12b4484e 100644 --- a/pkg/cri/sbserver/container_stats_list_linux.go +++ b/pkg/cri/sbserver/container_stats_list_linux.go @@ -24,7 +24,7 @@ import ( v1 "github.com/containerd/containerd/metrics/types/v1" v2 "github.com/containerd/containerd/metrics/types/v2" "github.com/containerd/containerd/protobuf" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" containerstore "github.com/containerd/containerd/pkg/cri/store/container" diff --git a/pkg/cri/sbserver/container_stats_list_windows.go b/pkg/cri/sbserver/container_stats_list_windows.go index 376505c404ef..cac378a0b685 100644 --- a/pkg/cri/sbserver/container_stats_list_windows.go +++ b/pkg/cri/sbserver/container_stats_list_windows.go @@ -22,7 +22,7 @@ import ( wstats "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats" "github.com/containerd/containerd/api/types" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" containerstore "github.com/containerd/containerd/pkg/cri/store/container" diff --git a/pkg/cri/sbserver/container_update_resources.go b/pkg/cri/sbserver/container_update_resources.go index 7a55b21dcab5..620798be81f1 100644 --- a/pkg/cri/sbserver/container_update_resources.go +++ b/pkg/cri/sbserver/container_update_resources.go @@ -23,7 +23,7 @@ import ( gocontext "context" "fmt" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/sbserver/events.go b/pkg/cri/sbserver/events.go index b14ee8c514c8..46c8e78a59ab 100644 --- a/pkg/cri/sbserver/events.go +++ b/pkg/cri/sbserver/events.go @@ -33,7 +33,7 @@ import ( sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ctrdutil "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/protobuf" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" "k8s.io/utils/clock" diff --git a/pkg/cri/sbserver/events_test.go b/pkg/cri/sbserver/events_test.go index 613e82bae0e8..7b8ddf1a3d27 100644 --- a/pkg/cri/sbserver/events_test.go +++ b/pkg/cri/sbserver/events_test.go @@ -22,7 +22,7 @@ import ( eventtypes "github.com/containerd/containerd/api/events" "github.com/containerd/containerd/protobuf" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" testingclock "k8s.io/utils/clock/testing" diff --git a/pkg/cri/sbserver/helpers.go b/pkg/cri/sbserver/helpers.go index eb7afb6609ff..387931f3feb5 100644 --- a/pkg/cri/sbserver/helpers.go +++ b/pkg/cri/sbserver/helpers.go @@ -27,7 +27,7 @@ import ( "strings" "time" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" diff --git a/pkg/cri/sbserver/helpers_test.go b/pkg/cri/sbserver/helpers_test.go index b9a9aa8a8553..901d6f3c264e 100644 --- a/pkg/cri/sbserver/helpers_test.go +++ b/pkg/cri/sbserver/helpers_test.go @@ -34,7 +34,7 @@ import ( "github.com/containerd/containerd/reference/docker" "github.com/containerd/containerd/runtime/linux/runctypes" runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" imagedigest "github.com/opencontainers/go-digest" runtimespec "github.com/opencontainers/runtime-spec/specs-go" diff --git a/pkg/cri/sbserver/podsandbox/sandbox_run.go b/pkg/cri/sbserver/podsandbox/sandbox_run.go index ed8f1aef7c86..11023614bb08 100644 --- a/pkg/cri/sbserver/podsandbox/sandbox_run.go +++ b/pkg/cri/sbserver/podsandbox/sandbox_run.go @@ -23,7 +23,7 @@ import ( "github.com/containerd/nri" v1 "github.com/containerd/nri/types/v1" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/davecgh/go-spew/spew" "github.com/hashicorp/go-multierror" "github.com/opencontainers/selinux/go-selinux" diff --git a/pkg/cri/sbserver/podsandbox/sandbox_run_test.go b/pkg/cri/sbserver/podsandbox/sandbox_run_test.go index 7d775d3076bf..defd61b0b19e 100644 --- a/pkg/cri/sbserver/podsandbox/sandbox_run_test.go +++ b/pkg/cri/sbserver/podsandbox/sandbox_run_test.go @@ -20,7 +20,7 @@ import ( goruntime "runtime" "testing" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/assert" diff --git a/pkg/cri/sbserver/podsandbox/sandbox_status.go b/pkg/cri/sbserver/podsandbox/sandbox_status.go index 599f57e916e0..dceb657a1303 100644 --- a/pkg/cri/sbserver/podsandbox/sandbox_status.go +++ b/pkg/cri/sbserver/podsandbox/sandbox_status.go @@ -27,7 +27,7 @@ import ( sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" "github.com/containerd/containerd/sandbox" "github.com/containerd/go-cni" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) diff --git a/pkg/cri/sbserver/restart.go b/pkg/cri/sbserver/restart.go index 7788f3ed132b..acae9c83a841 100644 --- a/pkg/cri/sbserver/restart.go +++ b/pkg/cri/sbserver/restart.go @@ -32,7 +32,7 @@ import ( criconfig "github.com/containerd/containerd/pkg/cri/config" "github.com/containerd/containerd/pkg/cri/sbserver/podsandbox" "github.com/containerd/containerd/platforms" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "golang.org/x/sync/errgroup" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/sbserver/sandbox_run.go b/pkg/cri/sbserver/sandbox_run.go index 0dde4fa84186..17eb63656111 100644 --- a/pkg/cri/sbserver/sandbox_run.go +++ b/pkg/cri/sbserver/sandbox_run.go @@ -27,7 +27,7 @@ import ( "time" "github.com/containerd/go-cni" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/hashicorp/go-multierror" "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/server/container_create.go b/pkg/cri/server/container_create.go index 17fce0246478..a94befa50ef6 100644 --- a/pkg/cri/server/container_create.go +++ b/pkg/cri/server/container_create.go @@ -23,7 +23,7 @@ import ( "path/filepath" "time" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/davecgh/go-spew/spew" imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtimespec "github.com/opencontainers/runtime-spec/specs-go" diff --git a/pkg/cri/server/container_stats_list_linux.go b/pkg/cri/server/container_stats_list_linux.go index beb781e3d4c1..20556a93b489 100644 --- a/pkg/cri/server/container_stats_list_linux.go +++ b/pkg/cri/server/container_stats_list_linux.go @@ -24,7 +24,7 @@ import ( v1 "github.com/containerd/containerd/metrics/types/v1" v2 "github.com/containerd/containerd/metrics/types/v2" "github.com/containerd/containerd/protobuf" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" containerstore "github.com/containerd/containerd/pkg/cri/store/container" diff --git a/pkg/cri/server/container_stats_list_windows.go b/pkg/cri/server/container_stats_list_windows.go index e2ec1918bb89..c7cb681368d9 100644 --- a/pkg/cri/server/container_stats_list_windows.go +++ b/pkg/cri/server/container_stats_list_windows.go @@ -22,7 +22,7 @@ import ( wstats "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats" "github.com/containerd/containerd/api/types" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" containerstore "github.com/containerd/containerd/pkg/cri/store/container" diff --git a/pkg/cri/server/container_update_resources.go b/pkg/cri/server/container_update_resources.go index 88edcdf006e3..b4d58c7f07b6 100644 --- a/pkg/cri/server/container_update_resources.go +++ b/pkg/cri/server/container_update_resources.go @@ -27,7 +27,7 @@ import ( "github.com/containerd/containerd/containers" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/log" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/server/events.go b/pkg/cri/server/events.go index 7e7f43059933..c7d31d5d8859 100644 --- a/pkg/cri/server/events.go +++ b/pkg/cri/server/events.go @@ -33,7 +33,7 @@ import ( sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ctrdutil "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/protobuf" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" "k8s.io/utils/clock" diff --git a/pkg/cri/server/events_test.go b/pkg/cri/server/events_test.go index 254ad87a1a53..e81b84d7c291 100644 --- a/pkg/cri/server/events_test.go +++ b/pkg/cri/server/events_test.go @@ -22,7 +22,7 @@ import ( eventtypes "github.com/containerd/containerd/api/events" "github.com/containerd/containerd/protobuf" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" testingclock "k8s.io/utils/clock/testing" diff --git a/pkg/cri/server/helpers.go b/pkg/cri/server/helpers.go index 9844b5564d4d..f678e693f221 100644 --- a/pkg/cri/server/helpers.go +++ b/pkg/cri/server/helpers.go @@ -39,7 +39,7 @@ import ( "github.com/containerd/containerd/reference/docker" "github.com/containerd/containerd/runtime/linux/runctypes" runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" diff --git a/pkg/cri/server/helpers_test.go b/pkg/cri/server/helpers_test.go index a184d470e21b..3b9be5b80911 100644 --- a/pkg/cri/server/helpers_test.go +++ b/pkg/cri/server/helpers_test.go @@ -34,7 +34,7 @@ import ( "github.com/containerd/containerd/reference/docker" "github.com/containerd/containerd/runtime/linux/runctypes" runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" imagedigest "github.com/opencontainers/go-digest" runtimespec "github.com/opencontainers/runtime-spec/specs-go" diff --git a/pkg/cri/server/nri-api.go b/pkg/cri/server/nri-api.go index 9ef35afa8d75..3d40ee2393a2 100644 --- a/pkg/cri/server/nri-api.go +++ b/pkg/cri/server/nri-api.go @@ -31,7 +31,7 @@ import ( cstore "github.com/containerd/containerd/pkg/cri/store/container" sstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ctrdutil "github.com/containerd/containerd/pkg/cri/util" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/opencontainers/runtime-spec/specs-go" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-tools/generate" diff --git a/pkg/cri/server/restart.go b/pkg/cri/server/restart.go index 3bcb7d8bcb06..f146fa16d2f3 100644 --- a/pkg/cri/server/restart.go +++ b/pkg/cri/server/restart.go @@ -30,7 +30,7 @@ import ( containerdimages "github.com/containerd/containerd/images" "github.com/containerd/containerd/log" "github.com/containerd/containerd/platforms" - "github.com/containerd/typeurl" + "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/sandbox_run.go b/pkg/cri/server/sandbox_run.go index 39a5a7b47793..b03d3349629a 100644 --- a/pkg/cri/server/sandbox_run.go +++ b/pkg/cri/server/sandbox_run.go @@ -28,7 +28,7 @@ import ( "time" cni "github.com/containerd/go-cni" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/davecgh/go-spew/spew" selinux "github.com/opencontainers/selinux/go-selinux" "github.com/sirupsen/logrus" diff --git a/pkg/cri/server/sandbox_run_test.go b/pkg/cri/server/sandbox_run_test.go index 91a197783790..bd048d9e87fd 100644 --- a/pkg/cri/server/sandbox_run_test.go +++ b/pkg/cri/server/sandbox_run_test.go @@ -23,7 +23,7 @@ import ( "testing" cni "github.com/containerd/go-cni" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/assert" diff --git a/pkg/streaming/streaming.go b/pkg/streaming/streaming.go index b89821d2373c..15fc6c3c1b68 100644 --- a/pkg/streaming/streaming.go +++ b/pkg/streaming/streaming.go @@ -19,7 +19,7 @@ package streaming import ( "context" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) type StreamManager interface { diff --git a/pkg/transfer/archive/exporter.go b/pkg/transfer/archive/exporter.go index 1833e7f779e2..a5ef208721d0 100644 --- a/pkg/transfer/archive/exporter.go +++ b/pkg/transfer/archive/exporter.go @@ -25,7 +25,7 @@ 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/typeurl" + "github.com/containerd/typeurl/v2" ) func init() { diff --git a/pkg/transfer/archive/importer.go b/pkg/transfer/archive/importer.go index 75effa1f983d..6519d5e44c0f 100644 --- a/pkg/transfer/archive/importer.go +++ b/pkg/transfer/archive/importer.go @@ -26,7 +26,7 @@ import ( "github.com/containerd/containerd/log" "github.com/containerd/containerd/pkg/streaming" tstreaming "github.com/containerd/containerd/pkg/transfer/streaming" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/pkg/transfer/image/imagestore.go b/pkg/transfer/image/imagestore.go index 953803b677c0..7afb909b2fea 100644 --- a/pkg/transfer/image/imagestore.go +++ b/pkg/transfer/image/imagestore.go @@ -31,7 +31,7 @@ import ( "github.com/containerd/containerd/pkg/unpack" "github.com/containerd/containerd/platforms" "github.com/containerd/containerd/remotes" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/pkg/transfer/image/registry.go b/pkg/transfer/image/registry.go index 7c0de7d071dc..6f44c7002208 100644 --- a/pkg/transfer/image/registry.go +++ b/pkg/transfer/image/registry.go @@ -33,7 +33,7 @@ import ( tstreaming "github.com/containerd/containerd/pkg/transfer/streaming" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/pkg/transfer/local/transfer.go b/pkg/transfer/local/transfer.go index d95e04e89b71..a014d7d3fa03 100644 --- a/pkg/transfer/local/transfer.go +++ b/pkg/transfer/local/transfer.go @@ -27,7 +27,7 @@ import ( "github.com/containerd/containerd/images" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/pkg/transfer" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "golang.org/x/sync/semaphore" ) diff --git a/pkg/transfer/plugins/plugins.go b/pkg/transfer/plugins/plugins.go index 2795f3885393..d122ec368b01 100644 --- a/pkg/transfer/plugins/plugins.go +++ b/pkg/transfer/plugins/plugins.go @@ -22,7 +22,7 @@ import ( "sync" "github.com/containerd/containerd/errdefs" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) var register = struct { diff --git a/pkg/transfer/proxy/transfer.go b/pkg/transfer/proxy/transfer.go index c1fa0c7e8397..e79e605585cb 100644 --- a/pkg/transfer/proxy/transfer.go +++ b/pkg/transfer/proxy/transfer.go @@ -27,7 +27,7 @@ import ( "github.com/containerd/containerd/pkg/streaming" "github.com/containerd/containerd/pkg/transfer" tstreaming "github.com/containerd/containerd/pkg/transfer/streaming" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "google.golang.org/protobuf/types/known/anypb" ) diff --git a/pkg/transfer/streaming/stream.go b/pkg/transfer/streaming/stream.go index d6dcf78bb7da..7352fda86953 100644 --- a/pkg/transfer/streaming/stream.go +++ b/pkg/transfer/streaming/stream.go @@ -29,7 +29,7 @@ import ( transferapi "github.com/containerd/containerd/api/types/transfer" "github.com/containerd/containerd/log" "github.com/containerd/containerd/pkg/streaming" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) const maxRead = 32 * 1024 diff --git a/pkg/transfer/streaming/stream_test.go b/pkg/transfer/streaming/stream_test.go index f2a905474442..12d8a87a8836 100644 --- a/pkg/transfer/streaming/stream_test.go +++ b/pkg/transfer/streaming/stream_test.go @@ -23,7 +23,7 @@ import ( "testing" "github.com/containerd/containerd/pkg/streaming" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) func FuzzSendAndReceive(f *testing.F) { diff --git a/pkg/transfer/streaming/writer.go b/pkg/transfer/streaming/writer.go index bb06572d7344..94db9d6a8153 100644 --- a/pkg/transfer/streaming/writer.go +++ b/pkg/transfer/streaming/writer.go @@ -25,7 +25,7 @@ import ( transferapi "github.com/containerd/containerd/api/types/transfer" "github.com/containerd/containerd/log" "github.com/containerd/containerd/pkg/streaming" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) func WriteByteStream(ctx context.Context, stream streaming.Stream) io.WriteCloser { diff --git a/protobuf/any.go b/protobuf/any.go index 8be32916253d..84da2a33daf0 100644 --- a/protobuf/any.go +++ b/protobuf/any.go @@ -17,7 +17,7 @@ package protobuf import ( - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "google.golang.org/protobuf/types/known/anypb" ) diff --git a/runtime/runtime.go b/runtime/runtime.go index 65c276c80de9..49a47eb7a1b2 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -21,7 +21,7 @@ import ( "time" "github.com/containerd/containerd/mount" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) // IO holds process IO information diff --git a/runtime/typeurl.go b/runtime/typeurl.go index eb54e250f34f..d4ad8ccc84f4 100644 --- a/runtime/typeurl.go +++ b/runtime/typeurl.go @@ -19,7 +19,7 @@ package runtime import ( "strconv" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" specs "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/runtime/v1/linux/runtime.go b/runtime/v1/linux/runtime.go index b7c8a4a4e136..1387e08017d8 100644 --- a/runtime/v1/linux/runtime.go +++ b/runtime/v1/linux/runtime.go @@ -48,7 +48,7 @@ import ( v1 "github.com/containerd/containerd/runtime/v1" "github.com/containerd/containerd/runtime/v1/shim/v1" "github.com/containerd/go-runc" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/sirupsen/logrus" "golang.org/x/sys/unix" diff --git a/runtime/v1/shim/service.go b/runtime/v1/shim/service.go index 7699fb163445..dd639b0338eb 100644 --- a/runtime/v1/shim/service.go +++ b/runtime/v1/shim/service.go @@ -43,7 +43,7 @@ import ( shimapi "github.com/containerd/containerd/runtime/v1/shim/v1" "github.com/containerd/containerd/sys/reaper" runc "github.com/containerd/go-runc" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "google.golang.org/grpc/codes" diff --git a/runtime/v2/bundle.go b/runtime/v2/bundle.go index 14c92fa0cda6..0e3c73d70840 100644 --- a/runtime/v2/bundle.go +++ b/runtime/v2/bundle.go @@ -26,7 +26,7 @@ import ( "github.com/containerd/containerd/identifiers" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/runtime/v2/bundle_linux_test.go b/runtime/v2/bundle_linux_test.go index f34859453ddf..07e077445b36 100644 --- a/runtime/v2/bundle_linux_test.go +++ b/runtime/v2/bundle_linux_test.go @@ -29,7 +29,7 @@ import ( "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/oci" "github.com/containerd/containerd/pkg/testutil" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/runtime/v2/runc/container.go b/runtime/v2/runc/container.go index 9aee5eef5612..2a3cf0159383 100644 --- a/runtime/v2/runc/container.go +++ b/runtime/v2/runc/container.go @@ -37,7 +37,7 @@ import ( "github.com/containerd/containerd/pkg/process" "github.com/containerd/containerd/pkg/stdio" "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/sirupsen/logrus" ) diff --git a/runtime/v2/runc/task/service.go b/runtime/v2/runc/task/service.go index e9f7c9aee0cc..c281491b6f29 100644 --- a/runtime/v2/runc/task/service.go +++ b/runtime/v2/runc/task/service.go @@ -47,7 +47,7 @@ import ( "github.com/containerd/containerd/sys/reaper" runcC "github.com/containerd/go-runc" "github.com/containerd/ttrpc" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/sirupsen/logrus" ) diff --git a/runtime/v2/runc/v1/service.go b/runtime/v2/runc/v1/service.go index 7a51e62fe728..79905aaac54d 100644 --- a/runtime/v2/runc/v1/service.go +++ b/runtime/v2/runc/v1/service.go @@ -49,7 +49,7 @@ import ( "github.com/containerd/containerd/runtime/v2/shim" "github.com/containerd/containerd/sys/reaper" runcC "github.com/containerd/go-runc" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/sirupsen/logrus" exec "golang.org/x/sys/execabs" "golang.org/x/sys/unix" diff --git a/runtime/v2/shim/util.go b/runtime/v2/shim/util.go index a81738c83823..b752ac0d12e9 100644 --- a/runtime/v2/shim/util.go +++ b/runtime/v2/shim/util.go @@ -33,7 +33,7 @@ import ( "github.com/containerd/containerd/protobuf/proto" "github.com/containerd/containerd/protobuf/types" "github.com/containerd/ttrpc" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" exec "golang.org/x/sys/execabs" ) diff --git a/sandbox.go b/sandbox.go index 5234c9ff6d4d..2e46da9f32ca 100644 --- a/sandbox.go +++ b/sandbox.go @@ -26,7 +26,7 @@ import ( "github.com/containerd/containerd/oci" "github.com/containerd/containerd/protobuf/types" api "github.com/containerd/containerd/sandbox" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) // Sandbox is a high level client to containerd's sandboxes. diff --git a/sandbox/controller.go b/sandbox/controller.go index 8d49937b8a37..d2f911bbf0ec 100644 --- a/sandbox/controller.go +++ b/sandbox/controller.go @@ -22,7 +22,7 @@ import ( "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/platforms" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) type CreateOptions struct { diff --git a/sandbox/helpers.go b/sandbox/helpers.go index 9f425ee17112..bfe0b23d33df 100644 --- a/sandbox/helpers.go +++ b/sandbox/helpers.go @@ -20,7 +20,7 @@ import ( "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/protobuf" gogo_types "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) // ToProto will map Sandbox struct to it's protobuf definition diff --git a/sandbox/store.go b/sandbox/store.go index 5db1b65c9bd2..cda646dde279 100644 --- a/sandbox/store.go +++ b/sandbox/store.go @@ -22,7 +22,7 @@ import ( "time" "github.com/containerd/containerd/errdefs" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) // Sandbox is an object stored in metadata database diff --git a/sandbox/store_test.go b/sandbox/store_test.go index 46783eec04d7..a1ff5cd24918 100644 --- a/sandbox/store_test.go +++ b/sandbox/store_test.go @@ -19,7 +19,7 @@ package sandbox import ( "testing" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/stretchr/testify/assert" ) diff --git a/services/containers/helpers.go b/services/containers/helpers.go index 75d7794e006e..e1bd5aff44fd 100644 --- a/services/containers/helpers.go +++ b/services/containers/helpers.go @@ -21,7 +21,7 @@ import ( "github.com/containerd/containerd/containers" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) func containersToProto(containers []containers.Container) []*api.Container { diff --git a/services/diff/local.go b/services/diff/local.go index c31accad6138..a6c5c39d4aca 100644 --- a/services/diff/local.go +++ b/services/diff/local.go @@ -27,7 +27,7 @@ import ( "github.com/containerd/containerd/mount" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/services" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "google.golang.org/grpc" diff --git a/services/streaming/service.go b/services/streaming/service.go index f9159e43add1..31c555ff8f5b 100644 --- a/services/streaming/service.go +++ b/services/streaming/service.go @@ -27,7 +27,7 @@ import ( "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "google.golang.org/grpc" ) diff --git a/services/tasks/local.go b/services/tasks/local.go index f7149cc58e22..976b1dead147 100644 --- a/services/tasks/local.go +++ b/services/tasks/local.go @@ -48,7 +48,7 @@ import ( "github.com/containerd/containerd/runtime/linux/runctypes" "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/containerd/containerd/services" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "google.golang.org/grpc" diff --git a/services/transfer/service.go b/services/transfer/service.go index e9195a3e2cf0..70fe39de537e 100644 --- a/services/transfer/service.go +++ b/services/transfer/service.go @@ -28,7 +28,7 @@ import ( "github.com/containerd/containerd/pkg/transfer/plugins" "github.com/containerd/containerd/plugin" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/task.go b/task.go index d63353dd72ff..be35611e7d43 100644 --- a/task.go +++ b/task.go @@ -43,7 +43,7 @@ import ( "github.com/containerd/containerd/rootfs" "github.com/containerd/containerd/runtime/linux/runctypes" "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" digest "github.com/opencontainers/go-digest" is "github.com/opencontainers/image-spec/specs-go" v1 "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/transfer.go b/transfer.go index 669f901173f8..9979aa75bd9b 100644 --- a/transfer.go +++ b/transfer.go @@ -28,7 +28,7 @@ import ( "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/transfer/proxy" "github.com/containerd/containerd/protobuf" - "github.com/containerd/typeurl" + "github.com/containerd/typeurl/v2" ) func (c *Client) Transfer(ctx context.Context, src interface{}, dest interface{}, opts ...transfer.Opt) error { diff --git a/vendor/github.com/containerd/typeurl/README.md b/vendor/github.com/containerd/typeurl/README.md index e3d0742f456c..d021e9672497 100644 --- a/vendor/github.com/containerd/typeurl/README.md +++ b/vendor/github.com/containerd/typeurl/README.md @@ -7,7 +7,7 @@ A Go package for managing the registration, marshaling, and unmarshaling of encoded types. -This package helps when types are sent over a ttrpc/GRPC API and marshaled as a protobuf [Any](https://pkg.go.dev/google.golang.org/protobuf@v1.27.1/types/known/anypb#Any) +This package helps when types are sent over a GRPC API and marshaled as a [protobuf.Any](https://github.com/gogo/protobuf/blob/master/protobuf/google/protobuf/any.proto). ## Project details diff --git a/vendor/github.com/containerd/typeurl/types.go b/vendor/github.com/containerd/typeurl/types.go index 2b9d8d84d8f2..647d419a293d 100644 --- a/vendor/github.com/containerd/typeurl/types.go +++ b/vendor/github.com/containerd/typeurl/types.go @@ -18,15 +18,13 @@ package typeurl import ( "encoding/json" - "errors" - "fmt" "path" "reflect" "sync" - gogoproto "github.com/gogo/protobuf/proto" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoregistry" + "github.com/gogo/protobuf/proto" + "github.com/gogo/protobuf/types" + "github.com/pkg/errors" ) var ( @@ -41,35 +39,10 @@ var ( // // To detect an error class, use errors.Is() functions to tell whether an // error is of this type. - var ( ErrNotFound = errors.New("not found") ) -type Any interface { - GetTypeUrl() string - GetValue() []byte -} - -type any struct { - typeURL string - value []byte -} - -func (a *any) GetTypeUrl() string { - if a == nil { - return "" - } - return a.typeURL -} - -func (a *any) GetValue() []byte { - if a == nil { - return nil - } - return a.value -} - // Register a type with a base URL for JSON marshaling. When the MarshalAny and // UnmarshalAny functions are called they will treat the Any type value as JSON. // To use protocol buffers for handling the Any value the proto.Register @@ -83,7 +56,7 @@ func Register(v interface{}, args ...string) { defer mu.Unlock() if et, ok := registry[t]; ok { if et != p { - panic(fmt.Errorf("type registered with alternate path %q != %q", et, p)) + panic(errors.Errorf("type registered with alternate path %q != %q", et, p)) } return } @@ -96,47 +69,41 @@ func TypeURL(v interface{}) (string, error) { u, ok := registry[tryDereference(v)] mu.RUnlock() if !ok { - switch t := v.(type) { - case proto.Message: - return string(t.ProtoReflect().Descriptor().FullName()), nil - case gogoproto.Message: - return gogoproto.MessageName(t), nil - default: - return "", fmt.Errorf("type %s: %w", reflect.TypeOf(v), ErrNotFound) + // fallback to the proto registry if it is a proto message + pb, ok := v.(proto.Message) + if !ok { + return "", errors.Wrapf(ErrNotFound, "type %s", reflect.TypeOf(v)) } + return proto.MessageName(pb), nil } return u, nil } // Is returns true if the type of the Any is the same as v. -func Is(any Any, v interface{}) bool { +func Is(any *types.Any, v interface{}) bool { // call to check that v is a pointer tryDereference(v) url, err := TypeURL(v) if err != nil { return false } - return any.GetTypeUrl() == url + return any.TypeUrl == url } // MarshalAny marshals the value v into an any with the correct TypeUrl. // If the provided object is already a proto.Any message, then it will be // returned verbatim. If it is of type proto.Message, it will be marshaled as a // protocol buffer. Otherwise, the object will be marshaled to json. -func MarshalAny(v interface{}) (Any, error) { +func MarshalAny(v interface{}) (*types.Any, error) { var marshal func(v interface{}) ([]byte, error) switch t := v.(type) { - case Any: + case *types.Any: // avoid reserializing the type if we have an any. return t, nil case proto.Message: marshal = func(v interface{}) ([]byte, error) { return proto.Marshal(t) } - case gogoproto.Message: - marshal = func(v interface{}) ([]byte, error) { - return gogoproto.Marshal(t) - } default: marshal = json.Marshal } @@ -150,15 +117,15 @@ func MarshalAny(v interface{}) (Any, error) { if err != nil { return nil, err } - return &any{ - typeURL: url, - value: data, + return &types.Any{ + TypeUrl: url, + Value: data, }, nil } // UnmarshalAny unmarshals the any type into a concrete type. -func UnmarshalAny(any Any) (interface{}, error) { - return UnmarshalByTypeURL(any.GetTypeUrl(), any.GetValue()) +func UnmarshalAny(any *types.Any) (interface{}, error) { + return UnmarshalByTypeURL(any.TypeUrl, any.Value) } // UnmarshalByTypeURL unmarshals the given type and value to into a concrete type. @@ -169,11 +136,11 @@ func UnmarshalByTypeURL(typeURL string, value []byte) (interface{}, error) { // UnmarshalTo unmarshals the any type into a concrete type passed in the out // argument. It is identical to UnmarshalAny, but lets clients provide a // destination type through the out argument. -func UnmarshalTo(any Any, out interface{}) error { - return UnmarshalToByTypeURL(any.GetTypeUrl(), any.GetValue(), out) +func UnmarshalTo(any *types.Any, out interface{}) error { + return UnmarshalToByTypeURL(any.TypeUrl, any.Value, out) } -// UnmarshalToByTypeURL unmarshals the given type and value into a concrete type passed +// UnmarshalTo unmarshals the given type and value into a concrete type passed // in the out argument. It is identical to UnmarshalByTypeURL, but lets clients // provide a destination type through the out argument. func UnmarshalToByTypeURL(typeURL string, value []byte, out interface{}) error { @@ -182,10 +149,6 @@ func UnmarshalToByTypeURL(typeURL string, value []byte, out interface{}) error { } func unmarshal(typeURL string, value []byte, v interface{}) (interface{}, error) { - if value == nil { - return nil, nil - } - t, err := getTypeByUrl(typeURL) if err != nil { return nil, err @@ -200,17 +163,12 @@ func unmarshal(typeURL string, value []byte, v interface{}) (interface{}, error) return nil, err } if typeURL != vURL { - return nil, fmt.Errorf("can't unmarshal type %q to output %q", typeURL, vURL) + return nil, errors.Errorf("can't unmarshal type %q to output %q", typeURL, vURL) } } if t.isProto { - switch t := v.(type) { - case proto.Message: - err = proto.Unmarshal(value, t) - case gogoproto.Message: - err = gogoproto.Unmarshal(value, t) - } + err = proto.Unmarshal(value, v.(proto.Message)) } else { err = json.Unmarshal(value, v) } @@ -235,7 +193,7 @@ func getTypeByUrl(url string) (urlType, error) { } mu.RUnlock() // fallback to proto registry - t := gogoproto.MessageType(url) + t := proto.MessageType(url) if t != nil { return urlType{ // get the underlying Elem because proto returns a pointer to the type @@ -243,12 +201,7 @@ func getTypeByUrl(url string) (urlType, error) { isProto: true, }, nil } - mt, err := protoregistry.GlobalTypes.FindMessageByURL(url) - if err != nil { - return urlType{}, fmt.Errorf("type with url %s: %w", url, ErrNotFound) - } - empty := mt.New().Interface() - return urlType{t: reflect.TypeOf(empty).Elem(), isProto: true}, nil + return urlType{}, errors.Wrapf(ErrNotFound, "type with url %s", url) } func tryDereference(v interface{}) reflect.Type { diff --git a/vendor/github.com/containerd/typeurl/v2/.gitignore b/vendor/github.com/containerd/typeurl/v2/.gitignore new file mode 100644 index 000000000000..d53846778b6a --- /dev/null +++ b/vendor/github.com/containerd/typeurl/v2/.gitignore @@ -0,0 +1,2 @@ +*.test +coverage.txt diff --git a/vendor/github.com/containerd/typeurl/v2/LICENSE b/vendor/github.com/containerd/typeurl/v2/LICENSE new file mode 100644 index 000000000000..584149b6ee28 --- /dev/null +++ b/vendor/github.com/containerd/typeurl/v2/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/typeurl/v2/README.md b/vendor/github.com/containerd/typeurl/v2/README.md new file mode 100644 index 000000000000..e3d0742f456c --- /dev/null +++ b/vendor/github.com/containerd/typeurl/v2/README.md @@ -0,0 +1,20 @@ +# typeurl + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/containerd/typeurl)](https://pkg.go.dev/github.com/containerd/typeurl) +[![Build Status](https://github.com/containerd/typeurl/workflows/CI/badge.svg)](https://github.com/containerd/typeurl/actions?query=workflow%3ACI) +[![codecov](https://codecov.io/gh/containerd/typeurl/branch/master/graph/badge.svg)](https://codecov.io/gh/containerd/typeurl) +[![Go Report Card](https://goreportcard.com/badge/github.com/containerd/typeurl)](https://goreportcard.com/report/github.com/containerd/typeurl) + +A Go package for managing the registration, marshaling, and unmarshaling of encoded types. + +This package helps when types are sent over a ttrpc/GRPC API and marshaled as a protobuf [Any](https://pkg.go.dev/google.golang.org/protobuf@v1.27.1/types/known/anypb#Any) + +## Project details + +**typeurl** 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/master/GOVERNANCE.md), + * [Maintainers](https://github.com/containerd/project/blob/master/MAINTAINERS), + * and [Contributing guidelines](https://github.com/containerd/project/blob/master/CONTRIBUTING.md) + +information in our [`containerd/project`](https://github.com/containerd/project) repository. diff --git a/vendor/github.com/containerd/typeurl/v2/doc.go b/vendor/github.com/containerd/typeurl/v2/doc.go new file mode 100644 index 000000000000..c0d0fd205333 --- /dev/null +++ b/vendor/github.com/containerd/typeurl/v2/doc.go @@ -0,0 +1,83 @@ +/* + 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 typeurl + +// Package typeurl assists with managing the registration, marshaling, and +// unmarshaling of types encoded as protobuf.Any. +// +// A protobuf.Any is a proto message that can contain any arbitrary data. It +// consists of two components, a TypeUrl and a Value, and its proto definition +// looks like this: +// +// message Any { +// string type_url = 1; +// bytes value = 2; +// } +// +// The TypeUrl is used to distinguish the contents from other proto.Any +// messages. This typeurl library manages these URLs to enable automagic +// marshaling and unmarshaling of the contents. +// +// For example, consider this go struct: +// +// type Foo struct { +// Field1 string +// Field2 string +// } +// +// To use typeurl, types must first be registered. This is typically done in +// the init function +// +// func init() { +// typeurl.Register(&Foo{}, "Foo") +// } +// +// This will register the type Foo with the url path "Foo". The arguments to +// Register are variadic, and are used to construct a url path. Consider this +// example, from the github.com/containerd/containerd/client package: +// +// func init() { +// const prefix = "types.containerd.io" +// // register TypeUrls for commonly marshaled external types +// major := strconv.Itoa(specs.VersionMajor) +// typeurl.Register(&specs.Spec{}, prefix, "opencontainers/runtime-spec", major, "Spec") +// // this function has more Register calls, which are elided. +// } +// +// This registers several types under a more complex url, which ends up mapping +// to `types.containerd.io/opencontainers/runtime-spec/1/Spec` (or some other +// value for major). +// +// Once a type is registered, it can be marshaled to a proto.Any message simply +// by calling `MarshalAny`, like this: +// +// foo := &Foo{Field1: "value1", Field2: "value2"} +// anyFoo, err := typeurl.MarshalAny(foo) +// +// MarshalAny will resolve the correct URL for the type. If the type in +// question implements the proto.Message interface, then it will be marshaled +// as a proto message. Otherwise, it will be marshaled as json. This means that +// typeurl will work on any arbitrary data, whether or not it has a proto +// definition, as long as it can be serialized to json. +// +// To unmarshal, the process is simply inverse: +// +// iface, err := typeurl.UnmarshalAny(anyFoo) +// foo := iface.(*Foo) +// +// The correct type is automatically chosen from the type registry, and the +// returned interface can be cast straight to that type. diff --git a/vendor/github.com/containerd/typeurl/v2/types.go b/vendor/github.com/containerd/typeurl/v2/types.go new file mode 100644 index 000000000000..41398f407596 --- /dev/null +++ b/vendor/github.com/containerd/typeurl/v2/types.go @@ -0,0 +1,273 @@ +/* + 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 typeurl + +import ( + "encoding/json" + "errors" + "fmt" + "path" + "reflect" + "sync" + + gogoproto "github.com/gogo/protobuf/proto" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoregistry" +) + +var ( + mu sync.RWMutex + registry = make(map[reflect.Type]string) +) + +// Definitions of common error types used throughout typeurl. +// +// These error types are used with errors.Wrap and errors.Wrapf to add context +// to an error. +// +// To detect an error class, use errors.Is() functions to tell whether an +// error is of this type. + +var ( + ErrNotFound = errors.New("not found") +) + +// Any contains an arbitrary protcol buffer message along with its type. +// +// While there is google.golang.org/protobuf/types/known/anypb.Any, +// we'd like to have our own to hide the underlying protocol buffer +// implementations from containerd clients. +// +// https://developers.google.com/protocol-buffers/docs/proto3#any +type Any interface { + // GetTypeUrl returns a URL/resource name that uniquely identifies + // the type of the serialized protocol buffer message. + GetTypeUrl() string + + // GetValue returns a valid serialized protocol buffer of the type that + // GetTypeUrl() indicates. + GetValue() []byte +} + +type anyType struct { + typeURL string + value []byte +} + +func (a *anyType) GetTypeUrl() string { + if a == nil { + return "" + } + return a.typeURL +} + +func (a *anyType) GetValue() []byte { + if a == nil { + return nil + } + return a.value +} + +// Register a type with a base URL for JSON marshaling. When the MarshalAny and +// UnmarshalAny functions are called they will treat the Any type value as JSON. +// To use protocol buffers for handling the Any value the proto.Register +// function should be used instead of this function. +func Register(v interface{}, args ...string) { + var ( + t = tryDereference(v) + p = path.Join(args...) + ) + mu.Lock() + defer mu.Unlock() + if et, ok := registry[t]; ok { + if et != p { + panic(fmt.Errorf("type registered with alternate path %q != %q", et, p)) + } + return + } + registry[t] = p +} + +// TypeURL returns the type url for a registered type. +func TypeURL(v interface{}) (string, error) { + mu.RLock() + u, ok := registry[tryDereference(v)] + mu.RUnlock() + if !ok { + switch t := v.(type) { + case proto.Message: + return string(t.ProtoReflect().Descriptor().FullName()), nil + case gogoproto.Message: + return gogoproto.MessageName(t), nil + default: + return "", fmt.Errorf("type %s: %w", reflect.TypeOf(v), ErrNotFound) + } + } + return u, nil +} + +// Is returns true if the type of the Any is the same as v. +func Is(any Any, v interface{}) bool { + // call to check that v is a pointer + tryDereference(v) + url, err := TypeURL(v) + if err != nil { + return false + } + return any.GetTypeUrl() == url +} + +// MarshalAny marshals the value v into an any with the correct TypeUrl. +// If the provided object is already a proto.Any message, then it will be +// returned verbatim. If it is of type proto.Message, it will be marshaled as a +// protocol buffer. Otherwise, the object will be marshaled to json. +func MarshalAny(v interface{}) (Any, error) { + var marshal func(v interface{}) ([]byte, error) + switch t := v.(type) { + case Any: + // avoid reserializing the type if we have an any. + return t, nil + case proto.Message: + marshal = func(v interface{}) ([]byte, error) { + return proto.Marshal(t) + } + case gogoproto.Message: + marshal = func(v interface{}) ([]byte, error) { + return gogoproto.Marshal(t) + } + default: + marshal = json.Marshal + } + + url, err := TypeURL(v) + if err != nil { + return nil, err + } + + data, err := marshal(v) + if err != nil { + return nil, err + } + return &anyType{ + typeURL: url, + value: data, + }, nil +} + +// UnmarshalAny unmarshals the any type into a concrete type. +func UnmarshalAny(any Any) (interface{}, error) { + return UnmarshalByTypeURL(any.GetTypeUrl(), any.GetValue()) +} + +// UnmarshalByTypeURL unmarshals the given type and value to into a concrete type. +func UnmarshalByTypeURL(typeURL string, value []byte) (interface{}, error) { + return unmarshal(typeURL, value, nil) +} + +// UnmarshalTo unmarshals the any type into a concrete type passed in the out +// argument. It is identical to UnmarshalAny, but lets clients provide a +// destination type through the out argument. +func UnmarshalTo(any Any, out interface{}) error { + return UnmarshalToByTypeURL(any.GetTypeUrl(), any.GetValue(), out) +} + +// UnmarshalToByTypeURL unmarshals the given type and value into a concrete type passed +// in the out argument. It is identical to UnmarshalByTypeURL, but lets clients +// provide a destination type through the out argument. +func UnmarshalToByTypeURL(typeURL string, value []byte, out interface{}) error { + _, err := unmarshal(typeURL, value, out) + return err +} + +func unmarshal(typeURL string, value []byte, v interface{}) (interface{}, error) { + if value == nil { + return nil, nil + } + + t, err := getTypeByUrl(typeURL) + if err != nil { + return nil, err + } + + if v == nil { + v = reflect.New(t.t).Interface() + } else { + // Validate interface type provided by client + vURL, err := TypeURL(v) + if err != nil { + return nil, err + } + if typeURL != vURL { + return nil, fmt.Errorf("can't unmarshal type %q to output %q", typeURL, vURL) + } + } + + if t.isProto { + switch t := v.(type) { + case proto.Message: + err = proto.Unmarshal(value, t) + case gogoproto.Message: + err = gogoproto.Unmarshal(value, t) + } + } else { + err = json.Unmarshal(value, v) + } + + return v, err +} + +type urlType struct { + t reflect.Type + isProto bool +} + +func getTypeByUrl(url string) (urlType, error) { + mu.RLock() + for t, u := range registry { + if u == url { + mu.RUnlock() + return urlType{ + t: t, + }, nil + } + } + mu.RUnlock() + // fallback to proto registry + t := gogoproto.MessageType(url) + if t != nil { + return urlType{ + // get the underlying Elem because proto returns a pointer to the type + t: t.Elem(), + isProto: true, + }, nil + } + mt, err := protoregistry.GlobalTypes.FindMessageByURL(url) + if err != nil { + return urlType{}, fmt.Errorf("type with url %s: %w", url, ErrNotFound) + } + empty := mt.New().Interface() + return urlType{t: reflect.TypeOf(empty).Elem(), isProto: true}, nil +} + +func tryDereference(v interface{}) reflect.Type { + t := reflect.TypeOf(v) + if t.Kind() == reflect.Ptr { + // require check of pointer but dereference to register + return t.Elem() + } + panic("v is not a pointer to a type") +} diff --git a/vendor/modules.txt b/vendor/modules.txt index f5e74e345bd5..c68dfaf2658d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -139,9 +139,12 @@ github.com/containerd/nri/types/v1 # github.com/containerd/ttrpc v1.1.1-0.20230127163717-32fab2374638 ## explicit; go 1.13 github.com/containerd/ttrpc -# github.com/containerd/typeurl v1.0.3-0.20220422153119-7f6e6d160d67 +# github.com/containerd/typeurl v1.0.2 ## explicit; go 1.13 github.com/containerd/typeurl +# github.com/containerd/typeurl/v2 v2.1.0 +## explicit; go 1.13 +github.com/containerd/typeurl/v2 # github.com/containerd/zfs v1.0.0 ## explicit; go 1.16 github.com/containerd/zfs