use typeurl funcs for marshalling anypb.Any
Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
This commit is contained in:
@@ -27,20 +27,20 @@ import (
|
||||
func ToProto(sandbox *Sandbox) *types.Sandbox {
|
||||
extensions := make(map[string]*gogo_types.Any)
|
||||
for k, v := range sandbox.Extensions {
|
||||
extensions[k] = protobuf.FromAny(v)
|
||||
extensions[k] = typeurl.MarshalProto(v)
|
||||
}
|
||||
return &types.Sandbox{
|
||||
SandboxID: sandbox.ID,
|
||||
Runtime: &types.Sandbox_Runtime{
|
||||
Name: sandbox.Runtime.Name,
|
||||
Options: protobuf.FromAny(sandbox.Runtime.Options),
|
||||
Options: typeurl.MarshalProto(sandbox.Runtime.Options),
|
||||
},
|
||||
Sandboxer: sandbox.Sandboxer,
|
||||
Labels: sandbox.Labels,
|
||||
CreatedAt: protobuf.ToTimestamp(sandbox.CreatedAt),
|
||||
UpdatedAt: protobuf.ToTimestamp(sandbox.UpdatedAt),
|
||||
Extensions: extensions,
|
||||
Spec: protobuf.FromAny(sandbox.Spec),
|
||||
Spec: typeurl.MarshalProto(sandbox.Spec),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"github.com/containerd/containerd/v2/core/sandbox"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf"
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
)
|
||||
@@ -206,17 +207,17 @@ func (s *remoteSandboxController) Update(
|
||||
}
|
||||
|
||||
func toAPISandbox(sb sandbox.Sandbox) (types.Sandbox, error) {
|
||||
options, err := protobuf.MarshalAnyToProto(sb.Runtime.Options)
|
||||
options, err := typeurl.MarshalAnyToProto(sb.Runtime.Options)
|
||||
if err != nil {
|
||||
return types.Sandbox{}, err
|
||||
}
|
||||
spec, err := protobuf.MarshalAnyToProto(sb.Spec)
|
||||
spec, err := typeurl.MarshalAnyToProto(sb.Spec)
|
||||
if err != nil {
|
||||
return types.Sandbox{}, err
|
||||
}
|
||||
extensions := make(map[string]*anypb.Any)
|
||||
for k, v := range sb.Extensions {
|
||||
pb, err := protobuf.MarshalAnyToProto(v)
|
||||
pb, err := typeurl.MarshalAnyToProto(v)
|
||||
if err != nil {
|
||||
return types.Sandbox{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user