From d414c0c1e8c487170b1d2f5af4946771645c6564 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 3 Dec 2020 16:20:30 +0100 Subject: [PATCH] replace uses of deprecated libcontainer/configs.Device Signed-off-by: Sebastiaan van Stijn --- oci/devices_linux.go | 7 +++---- oci/devices_linux_test.go | 4 ++-- oci/devices_unsupported.go | 20 -------------------- 3 files changed, 5 insertions(+), 26 deletions(-) delete mode 100644 oci/devices_unsupported.go diff --git a/oci/devices_linux.go b/oci/devices_linux.go index c0dfc28ce3..ca1c4886b9 100644 --- a/oci/devices_linux.go +++ b/oci/devices_linux.go @@ -6,14 +6,13 @@ import ( "path/filepath" "strings" - "github.com/opencontainers/runc/libcontainer/configs" "github.com/opencontainers/runc/libcontainer/devices" specs "github.com/opencontainers/runtime-spec/specs-go" "golang.org/x/sys/unix" ) -// Device transforms a libcontainer configs.Device to a specs.LinuxDevice object. -func Device(d *configs.Device) specs.LinuxDevice { +// Device transforms a libcontainer devices.Device to a specs.LinuxDevice object. +func Device(d *devices.Device) specs.LinuxDevice { return specs.LinuxDevice{ Type: string(d.Type), Path: d.Path, @@ -25,7 +24,7 @@ func Device(d *configs.Device) specs.LinuxDevice { } } -func deviceCgroup(d *configs.Device) specs.LinuxDeviceCgroup { +func deviceCgroup(d *devices.Device) specs.LinuxDeviceCgroup { return specs.LinuxDeviceCgroup{ Allow: true, Type: string(d.Type), diff --git a/oci/devices_linux_test.go b/oci/devices_linux_test.go index ebc032597b..42ef2a6151 100644 --- a/oci/devices_linux_test.go +++ b/oci/devices_linux_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/opencontainers/runc/libcontainer/configs" + "github.com/opencontainers/runc/libcontainer/devices" "golang.org/x/sys/unix" "gotest.tools/v3/assert" ) @@ -24,7 +24,7 @@ func TestDeviceMode(t *testing.T) { for _, tc := range tests { tc := tc t.Run(tc.name, func(t *testing.T) { - d := Device(&configs.Device{FileMode: tc.in}) + d := Device(&devices.Device{FileMode: tc.in}) assert.Equal(t, *d.FileMode, tc.out) }) } diff --git a/oci/devices_unsupported.go b/oci/devices_unsupported.go deleted file mode 100644 index af6dd3bda2..0000000000 --- a/oci/devices_unsupported.go +++ /dev/null @@ -1,20 +0,0 @@ -// +build !linux - -package oci // import "github.com/docker/docker/oci" - -import ( - "errors" - - "github.com/opencontainers/runc/libcontainer/configs" - specs "github.com/opencontainers/runtime-spec/specs-go" -) - -// Device transforms a libcontainer configs.Device to a specs.Device object. -// Not implemented -func Device(d *configs.Device) specs.LinuxDevice { return specs.LinuxDevice{} } - -// DevicesFromPath computes a list of devices and device permissions from paths (pathOnHost and pathInContainer) and cgroup permissions. -// Not implemented -func DevicesFromPath(pathOnHost, pathInContainer, cgroupPermissions string) (devs []specs.LinuxDevice, devPermissions []specs.LinuxDeviceCgroup, err error) { - return nil, nil, errors.New("oci/devices: unsupported platform") -}