remove uses of platforms.Platform alias

Commit 3c8469a782 removed uses of the api
types.Platform type from public interfaces, instead using the type from
the OCI image spec.

For convenience, it also introduced an alias in the platforms package.
While this alias allows packages that already import containerd's
platforms package (now a separate module), it may also cause confusion
(it's not clear that it's an alias for the OCI type), and for packages
that do not depend on containerd's platforms package / module may now
be resulting in an extra dependency.

Let's remove the use of this alias, and instead use the OCI type directly.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2024-05-28 14:56:30 +02:00
parent 45e30913bc
commit 446e63579c
10 changed files with 32 additions and 29 deletions

View File

@@ -23,8 +23,8 @@ import (
"github.com/containerd/containerd/api/types"
"github.com/containerd/containerd/v2/core/mount"
"github.com/containerd/platforms"
"github.com/containerd/typeurl/v2"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
)
type CreateOptions struct {
@@ -99,7 +99,7 @@ type Controller interface {
Start(ctx context.Context, sandboxID string) (ControllerInstance, error)
// Platform returns target sandbox OS that will be used by Controller.
// containerd will rely on this to generate proper OCI spec.
Platform(_ctx context.Context, _sandboxID string) (platforms.Platform, error)
Platform(_ctx context.Context, _sandboxID string) (imagespec.Platform, error)
// Stop will stop sandbox instance
Stop(ctx context.Context, sandboxID string, opts ...StopOpt) error
// Wait blocks until sandbox process exits.

View File

@@ -24,7 +24,7 @@ import (
"github.com/containerd/containerd/v2/core/mount"
"github.com/containerd/containerd/v2/core/sandbox"
"github.com/containerd/errdefs"
"github.com/containerd/platforms"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
"google.golang.org/protobuf/types/known/anypb"
)
@@ -78,14 +78,14 @@ func (s *remoteSandboxController) Start(ctx context.Context, sandboxID string) (
}, nil
}
func (s *remoteSandboxController) Platform(ctx context.Context, sandboxID string) (platforms.Platform, error) {
func (s *remoteSandboxController) Platform(ctx context.Context, sandboxID string) (imagespec.Platform, error) {
resp, err := s.client.Platform(ctx, &api.ControllerPlatformRequest{SandboxID: sandboxID})
if err != nil {
return platforms.Platform{}, errdefs.FromGRPC(err)
return imagespec.Platform{}, errdefs.FromGRPC(err)
}
platform := resp.GetPlatform()
return platforms.Platform{
return imagespec.Platform{
Architecture: platform.GetArchitecture(),
OS: platform.GetOS(),
Variant: platform.GetVariant(),