use typeurl funcs for marshalling anypb.Any
Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
This commit is contained in:
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf/proto"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf/types"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
@@ -164,7 +163,7 @@ func WriteExtensions(bkt *bolt.Bucket, extensions map[string]typeurl.Any) error
|
||||
}
|
||||
|
||||
for name, ext := range extensions {
|
||||
ext := protobuf.FromAny(ext)
|
||||
ext := typeurl.MarshalProto(ext)
|
||||
p, err := proto.Marshal(ext)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -206,7 +205,7 @@ func ReadExtensions(bkt *bolt.Bucket) (map[string]typeurl.Any, error) {
|
||||
|
||||
// WriteAny write a protobuf's Any type to the bucket
|
||||
func WriteAny(bkt *bolt.Bucket, name []byte, any typeurl.Any) error {
|
||||
pbany := protobuf.FromAny(any)
|
||||
pbany := typeurl.MarshalProto(any)
|
||||
if pbany == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
"github.com/containerd/containerd/v2/core/containers"
|
||||
"github.com/containerd/containerd/v2/pkg/filters"
|
||||
"github.com/containerd/containerd/v2/pkg/namespaces"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf/types"
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/containerd/log/logtest"
|
||||
@@ -48,7 +47,7 @@ func TestContainersList(t *testing.T) {
|
||||
ctx, db := testEnv(t)
|
||||
store := NewContainerStore(NewDB(db, nil, nil))
|
||||
spec := &specs.Spec{}
|
||||
encoded, err := protobuf.MarshalAnyToProto(spec)
|
||||
encoded, err := typeurl.MarshalAnyToProto(spec)
|
||||
require.NoError(t, err)
|
||||
|
||||
testset := map[string]*containers.Container{}
|
||||
@@ -178,11 +177,11 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
|
||||
spec = &specs.Spec{}
|
||||
)
|
||||
|
||||
encoded, err := protobuf.MarshalAnyToProto(spec)
|
||||
encoded, err := typeurl.MarshalAnyToProto(spec)
|
||||
require.NoError(t, err)
|
||||
|
||||
spec.Annotations = map[string]string{"updated": "true"}
|
||||
encodedUpdated, err := protobuf.MarshalAnyToProto(spec)
|
||||
encodedUpdated, err := typeurl.MarshalAnyToProto(spec)
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, testcase := range []struct {
|
||||
|
||||
Reference in New Issue
Block a user