use typeurl funcs for marshalling anypb.Any
Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
This commit is contained in:
@@ -38,7 +38,7 @@ func containersToProto(containers []containers.Container) []*api.Container {
|
||||
func containerToProto(container *containers.Container) *api.Container {
|
||||
extensions := make(map[string]*types.Any)
|
||||
for k, v := range container.Extensions {
|
||||
extensions[k] = protobuf.FromAny(v)
|
||||
extensions[k] = typeurl.MarshalProto(v)
|
||||
}
|
||||
return &api.Container{
|
||||
ID: container.ID,
|
||||
@@ -46,9 +46,9 @@ func containerToProto(container *containers.Container) *api.Container {
|
||||
Image: container.Image,
|
||||
Runtime: &api.Container_Runtime{
|
||||
Name: container.Runtime.Name,
|
||||
Options: protobuf.FromAny(container.Runtime.Options),
|
||||
Options: typeurl.MarshalProto(container.Runtime.Options),
|
||||
},
|
||||
Spec: protobuf.FromAny(container.Spec),
|
||||
Spec: typeurl.MarshalProto(container.Spec),
|
||||
Snapshotter: container.Snapshotter,
|
||||
SnapshotKey: container.SnapshotKey,
|
||||
CreatedAt: protobuf.ToTimestamp(container.CreatedAt),
|
||||
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/containerd/plugin"
|
||||
"github.com/containerd/plugin/registry"
|
||||
"github.com/containerd/ttrpc"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -120,7 +121,7 @@ func toProto(env *events.Envelope) *types.Envelope {
|
||||
Timestamp: protobuf.ToTimestamp(env.Timestamp),
|
||||
Namespace: env.Namespace,
|
||||
Topic: env.Topic,
|
||||
Event: protobuf.FromAny(env.Event),
|
||||
Event: typeurl.MarshalProto(env.Event),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
|
||||
api "github.com/containerd/containerd/api/services/streaming/v1"
|
||||
"github.com/containerd/containerd/v2/core/streaming"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf"
|
||||
ptypes "github.com/containerd/containerd/v2/pkg/protobuf/types"
|
||||
"github.com/containerd/containerd/v2/plugins"
|
||||
"github.com/containerd/errdefs"
|
||||
@@ -92,7 +91,7 @@ func (s *service) Stream(srv api.Streaming_StreamServer) error {
|
||||
}
|
||||
|
||||
// Send response packet after registering stream
|
||||
if err := srv.Send(protobuf.FromAny(emptyResponse)); err != nil {
|
||||
if err := srv.Send(typeurl.MarshalProto(emptyResponse)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -111,7 +110,7 @@ type serviceStream struct {
|
||||
}
|
||||
|
||||
func (ss *serviceStream) Send(a typeurl.Any) (err error) {
|
||||
err = errdefs.FromGRPC(ss.s.Send(protobuf.FromAny(a)))
|
||||
err = errdefs.FromGRPC(ss.s.Send(typeurl.MarshalProto(a)))
|
||||
if !errors.Is(err, io.EOF) {
|
||||
err = errdefs.FromGRPC(err)
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ func (l *local) ListPids(ctx context.Context, r *api.ListPidsRequest, _ ...grpc.
|
||||
Pid: p.Pid,
|
||||
}
|
||||
if p.Info != nil {
|
||||
a, err := protobuf.MarshalAnyToProto(p.Info)
|
||||
a, err := typeurl.MarshalAnyToProto(p.Info)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal process %d info: %w", p.Pid, err)
|
||||
}
|
||||
@@ -576,7 +576,7 @@ func (l *local) Checkpoint(ctx context.Context, r *api.CheckpointTaskRequest, _
|
||||
return nil, err
|
||||
}
|
||||
// write the config to the content store
|
||||
pbany := protobuf.FromAny(container.Spec)
|
||||
pbany := typeurl.MarshalProto(container.Spec)
|
||||
data, err := proto.Marshal(pbany)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user