use typeurl funcs for marshalling anypb.Any
Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
This commit is contained in:
@@ -55,7 +55,6 @@ import (
|
||||
"github.com/containerd/containerd/v2/defaults"
|
||||
"github.com/containerd/containerd/v2/pkg/dialer"
|
||||
"github.com/containerd/containerd/v2/pkg/namespaces"
|
||||
"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"
|
||||
@@ -898,7 +897,7 @@ func (c *Client) RuntimeInfo(ctx context.Context, runtimePath string, runtimeOpt
|
||||
}
|
||||
var err error
|
||||
if runtimeOptions != nil {
|
||||
rr.Options, err = protobuf.MarshalAnyToProto(runtimeOptions)
|
||||
rr.Options, err = typeurl.MarshalAnyToProto(runtimeOptions)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal %T: %w", runtimeOptions, err)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import (
|
||||
"github.com/containerd/containerd/v2/core/images"
|
||||
"github.com/containerd/containerd/v2/pkg/cio"
|
||||
"github.com/containerd/containerd/v2/pkg/oci"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf"
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/containerd/fifo"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
@@ -288,7 +287,7 @@ func (c *container) NewTask(ctx context.Context, ioCreate cio.Creator, opts ...N
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
request.Options = protobuf.FromAny(o)
|
||||
request.Options = typeurl.MarshalProto(o)
|
||||
}
|
||||
t := &task{
|
||||
client: c.client,
|
||||
|
||||
@@ -28,10 +28,10 @@ import (
|
||||
"github.com/containerd/containerd/v2/core/containers"
|
||||
"github.com/containerd/containerd/v2/core/diff"
|
||||
"github.com/containerd/containerd/v2/core/images"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf/proto"
|
||||
"github.com/containerd/containerd/v2/pkg/rootfs"
|
||||
"github.com/containerd/platforms"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/opencontainers/go-digest"
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
@@ -54,7 +54,7 @@ func WithCheckpointImage(ctx context.Context, client *Client, c *containers.Cont
|
||||
|
||||
// WithCheckpointTask includes the running task
|
||||
func WithCheckpointTask(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error {
|
||||
opt, err := protobuf.MarshalAnyToProto(copts)
|
||||
opt, err := typeurl.MarshalAnyToProto(copts)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
@@ -96,7 +96,7 @@ func WithCheckpointTask(ctx context.Context, client *Client, c *containers.Conta
|
||||
// WithCheckpointRuntime includes the container runtime info
|
||||
func WithCheckpointRuntime(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error {
|
||||
if c.Runtime.Options != nil && c.Runtime.Options.GetValue() != nil {
|
||||
opt := protobuf.FromAny(c.Runtime.Options)
|
||||
opt := typeurl.MarshalProto(c.Runtime.Options)
|
||||
data, err := proto.Marshal(opt)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
"github.com/containerd/containerd/v2/core/snapshots"
|
||||
"github.com/containerd/containerd/v2/pkg/namespaces"
|
||||
"github.com/containerd/containerd/v2/pkg/oci"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf"
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/opencontainers/image-spec/identity"
|
||||
@@ -321,7 +320,7 @@ func WithSpec(s *oci.Spec, opts ...oci.SpecOpts) NewContainerOpts {
|
||||
}
|
||||
|
||||
var err error
|
||||
c.Spec, err = protobuf.MarshalAnyToProto(s)
|
||||
c.Spec, err = typeurl.MarshalAnyToProto(s)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ func (r *remoteContainers) Delete(ctx context.Context, id string) error {
|
||||
func containerToProto(container *containers.Container) *containersapi.Container {
|
||||
extensions := make(map[string]*ptypes.Any)
|
||||
for k, v := range container.Extensions {
|
||||
extensions[k] = protobuf.FromAny(v)
|
||||
extensions[k] = typeurl.MarshalProto(v)
|
||||
}
|
||||
return &containersapi.Container{
|
||||
ID: container.ID,
|
||||
@@ -160,9 +160,9 @@ func containerToProto(container *containers.Container) *containersapi.Container
|
||||
Image: container.Image,
|
||||
Runtime: &containersapi.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,
|
||||
Extensions: extensions,
|
||||
|
||||
@@ -53,7 +53,7 @@ func (e *eventRemote) Publish(ctx context.Context, topic string, event events.Ev
|
||||
}
|
||||
req := &eventsapi.PublishRequest{
|
||||
Topic: topic,
|
||||
Event: protobuf.FromAny(evt),
|
||||
Event: typeurl.MarshalProto(evt),
|
||||
}
|
||||
if _, err := e.client.Publish(ctx, req); err != nil {
|
||||
return errdefs.FromGRPC(err)
|
||||
@@ -67,7 +67,7 @@ func (e *eventRemote) Forward(ctx context.Context, envelope *events.Envelope) er
|
||||
Timestamp: protobuf.ToTimestamp(envelope.Timestamp),
|
||||
Namespace: envelope.Namespace,
|
||||
Topic: envelope.Topic,
|
||||
Event: protobuf.FromAny(envelope.Event),
|
||||
Event: typeurl.MarshalProto(envelope.Event),
|
||||
},
|
||||
}
|
||||
if _, err := e.client.Forward(ctx, req); err != nil {
|
||||
|
||||
@@ -363,7 +363,7 @@ func (t *task) Exec(ctx context.Context, id string, spec *specs.Process, ioCreat
|
||||
i.Close()
|
||||
}
|
||||
}()
|
||||
pSpec, err := protobuf.MarshalAnyToProto(spec)
|
||||
pSpec, err := typeurl.MarshalAnyToProto(spec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -463,7 +463,7 @@ func (t *task) Checkpoint(ctx context.Context, opts ...CheckpointTaskOpts) (Imag
|
||||
}
|
||||
request.ParentCheckpoint = i.ParentCheckpoint.String()
|
||||
if i.Options != nil {
|
||||
o, err := protobuf.MarshalAnyToProto(i.Options)
|
||||
o, err := typeurl.MarshalAnyToProto(i.Options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -552,7 +552,7 @@ func (t *task) Update(ctx context.Context, opts ...UpdateTaskOpts) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
request.Resources = protobuf.FromAny(r)
|
||||
request.Resources = typeurl.MarshalProto(r)
|
||||
}
|
||||
if i.Annotations != nil {
|
||||
request.Annotations = i.Annotations
|
||||
|
||||
Reference in New Issue
Block a user