Skip to content

Commit e32090e

Browse files
authored
Merge pull request containerd#10273 from thaJeztah/remove_use_of_platform_alias
remove uses of platforms.Platform alias
2 parents 45e3091 + 446e635 commit e32090e

File tree

10 files changed

+32
-29
lines changed

10 files changed

+32
-29
lines changed

core/sandbox/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323

2424
"github.com/containerd/containerd/api/types"
2525
"github.com/containerd/containerd/v2/core/mount"
26-
"github.com/containerd/platforms"
2726
"github.com/containerd/typeurl/v2"
27+
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
2828
)
2929

3030
type CreateOptions struct {
@@ -99,7 +99,7 @@ type Controller interface {
9999
Start(ctx context.Context, sandboxID string) (ControllerInstance, error)
100100
// Platform returns target sandbox OS that will be used by Controller.
101101
// containerd will rely on this to generate proper OCI spec.
102-
Platform(_ctx context.Context, _sandboxID string) (platforms.Platform, error)
102+
Platform(_ctx context.Context, _sandboxID string) (imagespec.Platform, error)
103103
// Stop will stop sandbox instance
104104
Stop(ctx context.Context, sandboxID string, opts ...StopOpt) error
105105
// Wait blocks until sandbox process exits.

core/sandbox/proxy/controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/containerd/containerd/v2/core/mount"
2525
"github.com/containerd/containerd/v2/core/sandbox"
2626
"github.com/containerd/errdefs"
27-
"github.com/containerd/platforms"
27+
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
2828
"google.golang.org/protobuf/types/known/anypb"
2929
)
3030

@@ -78,14 +78,14 @@ func (s *remoteSandboxController) Start(ctx context.Context, sandboxID string) (
7878
}, nil
7979
}
8080

81-
func (s *remoteSandboxController) Platform(ctx context.Context, sandboxID string) (platforms.Platform, error) {
81+
func (s *remoteSandboxController) Platform(ctx context.Context, sandboxID string) (imagespec.Platform, error) {
8282
resp, err := s.client.Platform(ctx, &api.ControllerPlatformRequest{SandboxID: sandboxID})
8383
if err != nil {
84-
return platforms.Platform{}, errdefs.FromGRPC(err)
84+
return imagespec.Platform{}, errdefs.FromGRPC(err)
8585
}
8686

8787
platform := resp.GetPlatform()
88-
return platforms.Platform{
88+
return imagespec.Platform{
8989
Architecture: platform.GetArchitecture(),
9090
OS: platform.GetOS(),
9191
Variant: platform.GetVariant(),

internal/cri/server/container_create.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
351351
// volumeMounts sets up image volumes for container. Rely on the removal of container
352352
// root directory to do cleanup. Note that image volume will be skipped, if there is criMounts
353353
// specified with the same destination.
354-
func (c *criService) volumeMounts(platform platforms.Platform, containerRootDir string, containerConfig *runtime.ContainerConfig, config *imagespec.ImageConfig) []*runtime.Mount {
354+
func (c *criService) volumeMounts(platform imagespec.Platform, containerRootDir string, containerConfig *runtime.ContainerConfig, config *imagespec.ImageConfig) []*runtime.Mount {
355355
var uidMappings, gidMappings []*runtime.IDMapping
356356
if platform.OS == "linux" {
357357
if usernsOpts := containerConfig.GetLinux().GetSecurityContext().GetNamespaceOptions().GetUsernsOptions(); usernsOpts != nil {
@@ -399,7 +399,7 @@ func (c *criService) volumeMounts(platform platforms.Platform, containerRootDir
399399
}
400400

401401
// runtimeSpec returns a default runtime spec used in cri-containerd.
402-
func (c *criService) runtimeSpec(id string, platform platforms.Platform, baseSpecFile string, opts ...oci.SpecOpts) (*runtimespec.Spec, error) {
402+
func (c *criService) runtimeSpec(id string, platform imagespec.Platform, baseSpecFile string, opts ...oci.SpecOpts) (*runtimespec.Spec, error) {
403403
// GenerateSpec needs namespace.
404404
ctx := util.NamespacedContext()
405405
container := &containers.Container{ID: id}
@@ -482,7 +482,7 @@ func generateUserString(username string, uid, gid *runtime.Int64Value) (string,
482482
// runtime information (rootfs mounted), or platform specific checks with
483483
// no defined workaround (yet) to specify for other platforms.
484484
func (c *criService) platformSpecOpts(
485-
platform platforms.Platform,
485+
platform imagespec.Platform,
486486
config *runtime.ContainerConfig,
487487
imageConfig *imagespec.ImageConfig,
488488
) ([]oci.SpecOpts, error) {
@@ -529,7 +529,7 @@ func (c *criService) platformSpecOpts(
529529

530530
// buildContainerSpec build container's OCI spec depending on controller's target platform OS.
531531
func (c *criService) buildContainerSpec(
532-
platform platforms.Platform,
532+
platform imagespec.Platform,
533533
id string,
534534
sandboxID string,
535535
sandboxPid uint32,

internal/cri/server/container_create_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func TestVolumeMounts(t *testing.T) {
241241

242242
for _, test := range []struct {
243243
desc string
244-
platform platforms.Platform
244+
platform imagespec.Platform
245245
criMounts []*runtime.Mount
246246
usernsEnabled bool
247247
imageVolumes map[string]struct{}
@@ -293,7 +293,7 @@ func TestVolumeMounts(t *testing.T) {
293293
},
294294
{
295295
desc: "should make relative paths absolute on Linux",
296-
platform: platforms.Platform{OS: "linux"},
296+
platform: imagespec.Platform{OS: "linux"},
297297
imageVolumes: map[string]struct{}{
298298
"./test-volume-1": {},
299299
"C:/test-volume-2": {},
@@ -309,7 +309,7 @@ func TestVolumeMounts(t *testing.T) {
309309
},
310310
{
311311
desc: "should include mappings for image volumes on Linux",
312-
platform: platforms.Platform{OS: "linux"},
312+
platform: imagespec.Platform{OS: "linux"},
313313
usernsEnabled: true,
314314
imageVolumes: map[string]struct{}{
315315
"/test-volume-1/": {},
@@ -323,7 +323,7 @@ func TestVolumeMounts(t *testing.T) {
323323
},
324324
{
325325
desc: "should NOT include mappings for image volumes on Linux if !userns",
326-
platform: platforms.Platform{OS: "linux"},
326+
platform: imagespec.Platform{OS: "linux"},
327327
usernsEnabled: false,
328328
imageVolumes: map[string]struct{}{
329329
"/test-volume-1/": {},
@@ -336,7 +336,7 @@ func TestVolumeMounts(t *testing.T) {
336336
},
337337
{
338338
desc: "should convert rel imageVolume paths to abs paths and add userns mappings",
339-
platform: platforms.Platform{OS: "linux"},
339+
platform: imagespec.Platform{OS: "linux"},
340340
usernsEnabled: true,
341341
imageVolumes: map[string]struct{}{
342342
"test-volume-1/": {},

internal/cri/server/images/service.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/containerd/platforms"
3333
docker "github.com/distribution/reference"
3434
imagedigest "github.com/opencontainers/go-digest"
35+
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
3536

3637
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
3738
)
@@ -44,7 +45,7 @@ type imageClient interface {
4445

4546
type ImagePlatform struct {
4647
Snapshotter string
47-
Platform platforms.Platform
48+
Platform imagespec.Platform
4849
}
4950

5051
type CRIImageService struct {

internal/cri/server/podsandbox/controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/containerd/log"
2525
"github.com/containerd/plugin"
2626
"github.com/containerd/plugin/registry"
27+
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
2728
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
2829

2930
eventtypes "github.com/containerd/containerd/api/events"
@@ -134,7 +135,7 @@ type Controller struct {
134135

135136
var _ sandbox.Controller = (*Controller)(nil)
136137

137-
func (c *Controller) Platform(_ctx context.Context, _sandboxID string) (platforms.Platform, error) {
138+
func (c *Controller) Platform(_ctx context.Context, _sandboxID string) (imagespec.Platform, error) {
138139
return platforms.DefaultSpec(), nil
139140
}
140141

internal/cri/server/sandbox_service.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"fmt"
2222
"time"
2323

24-
"github.com/containerd/platforms"
24+
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
2525

2626
"github.com/containerd/containerd/v2/client"
2727
"github.com/containerd/containerd/v2/core/sandbox"
@@ -94,10 +94,10 @@ func (c *criSandboxService) SandboxStatus(ctx context.Context, sandboxer string,
9494
return ctrl.Status(ctx, sandboxID, verbose)
9595
}
9696

97-
func (c *criSandboxService) SandboxPlatform(ctx context.Context, sandboxer string, sandboxID string) (platforms.Platform, error) {
97+
func (c *criSandboxService) SandboxPlatform(ctx context.Context, sandboxer string, sandboxID string) (imagespec.Platform, error) {
9898
ctrl, err := c.SandboxController(sandboxer)
9999
if err != nil {
100-
return platforms.Platform{}, err
100+
return imagespec.Platform{}, err
101101
}
102102
return ctrl.Platform(ctx, sandboxID)
103103
}

internal/cri/server/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import (
2828

2929
"github.com/containerd/go-cni"
3030
"github.com/containerd/log"
31-
"github.com/containerd/platforms"
3231
"github.com/containerd/typeurl/v2"
32+
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
3333
"github.com/opencontainers/runtime-spec/specs-go/features"
3434
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
3535
"k8s.io/kubelet/pkg/cri/streaming"
@@ -79,7 +79,7 @@ type sandboxService interface {
7979
StopSandbox(ctx context.Context, sandboxer, sandboxID string, opts ...sandbox.StopOpt) error
8080
ShutdownSandbox(ctx context.Context, sandboxer string, sandboxID string) error
8181
SandboxStatus(ctx context.Context, sandboxer string, sandboxID string, verbose bool) (sandbox.ControllerStatus, error)
82-
SandboxPlatform(ctx context.Context, sandboxer string, sandboxID string) (platforms.Platform, error)
82+
SandboxPlatform(ctx context.Context, sandboxer string, sandboxID string) (imagespec.Platform, error)
8383
SandboxController(sandboxer string) (sandbox.Controller, error)
8484
}
8585

internal/cri/server/service_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/containerd/errdefs"
2323
"github.com/containerd/go-cni"
2424
"github.com/containerd/platforms"
25+
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
2526

2627
"github.com/containerd/containerd/api/types"
2728
containerd "github.com/containerd/containerd/v2/client"
@@ -62,7 +63,7 @@ func (f *fakeSandboxService) SandboxStatus(ctx context.Context, sandboxer string
6263
return sandbox.ControllerStatus{}, errdefs.ErrNotImplemented
6364
}
6465

65-
func (f *fakeSandboxService) SandboxPlatform(ctx context.Context, sandboxer string, sandboxID string) (platforms.Platform, error) {
66+
func (f *fakeSandboxService) SandboxPlatform(ctx context.Context, sandboxer string, sandboxID string) (imagespec.Platform, error) {
6667
return platforms.DefaultSpec(), nil
6768
}
6869

@@ -80,7 +81,7 @@ func (f fakeSandboxController) Start(ctx context.Context, sandboxID string) (san
8081
return sandbox.ControllerInstance{}, errdefs.ErrNotImplemented
8182
}
8283

83-
func (f fakeSandboxController) Platform(_ctx context.Context, _sandboxID string) (platforms.Platform, error) {
84+
func (f fakeSandboxController) Platform(_ctx context.Context, _sandboxID string) (imagespec.Platform, error) {
8485
return platforms.DefaultSpec(), nil
8586
}
8687

plugins/sandbox/controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import (
2424

2525
"github.com/containerd/errdefs"
2626
"github.com/containerd/log"
27-
"github.com/containerd/platforms"
2827
"github.com/containerd/plugin"
2928
"github.com/containerd/plugin/registry"
29+
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
3030
"google.golang.org/protobuf/types/known/anypb"
3131

3232
runtimeAPI "github.com/containerd/containerd/api/runtime/sandbox/v1"
@@ -198,18 +198,18 @@ func (c *controllerLocal) Start(ctx context.Context, sandboxID string) (sandbox.
198198
}, nil
199199
}
200200

201-
func (c *controllerLocal) Platform(ctx context.Context, sandboxID string) (platforms.Platform, error) {
201+
func (c *controllerLocal) Platform(ctx context.Context, sandboxID string) (imagespec.Platform, error) {
202202
svc, err := c.getSandbox(ctx, sandboxID)
203203
if err != nil {
204-
return platforms.Platform{}, err
204+
return imagespec.Platform{}, err
205205
}
206206

207207
response, err := svc.Platform(ctx, &runtimeAPI.PlatformRequest{SandboxID: sandboxID})
208208
if err != nil {
209-
return platforms.Platform{}, fmt.Errorf("failed to get sandbox platform: %w", errdefs.FromGRPC(err))
209+
return imagespec.Platform{}, fmt.Errorf("failed to get sandbox platform: %w", errdefs.FromGRPC(err))
210210
}
211211

212-
var platform platforms.Platform
212+
var platform imagespec.Platform
213213
if p := response.GetPlatform(); p != nil {
214214
platform.OS = p.OS
215215
platform.Architecture = p.Architecture

0 commit comments

Comments
 (0)