1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

replace uses of deprecated libcontainer/configs.Device

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-12-03 16:20:30 +01:00
parent a927fc7831
commit d414c0c1e8
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
3 changed files with 5 additions and 26 deletions

View file

@ -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),

View file

@ -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)
})
}

View file

@ -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")
}