Use typeurl.Any instead of github.com/gogo/protobuf/types.Any

This commit upgrades github.com/containerd/typeurl to use typeurl.Any.
The interface hides gogo/protobuf/types.Any from containerd's Go client.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato
2022-03-22 00:40:39 +00:00
parent 551516a18d
commit 96b16b447d
42 changed files with 336 additions and 152 deletions

View File

@@ -27,9 +27,9 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/protobuf"
"github.com/containerd/containerd/snapshots"
"github.com/containerd/typeurl"
"github.com/gogo/protobuf/types"
"github.com/opencontainers/image-spec/identity"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)
@@ -57,7 +57,7 @@ type InfoConfig struct {
func WithRuntime(name string, options interface{}) NewContainerOpts {
return func(ctx context.Context, client *Client, c *containers.Container) error {
var (
any *types.Any
any typeurl.Any
err error
)
if options != nil {
@@ -288,9 +288,9 @@ func WithContainerExtension(name string, extension interface{}) NewContainerOpts
}
if c.Extensions == nil {
c.Extensions = make(map[string]types.Any)
c.Extensions = make(map[string]typeurl.Any)
}
c.Extensions[name] = *any
c.Extensions[name] = any
return nil
}
}
@@ -315,7 +315,7 @@ func WithSpec(s *oci.Spec, opts ...oci.SpecOpts) NewContainerOpts {
}
var err error
c.Spec, err = typeurl.MarshalAny(s)
c.Spec, err = protobuf.MarshalAnyToProto(s)
return err
}
}