From 83e60ddaf04ee5ba58749f6d48cc8daf126b1161 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 4 Apr 2026 19:27:02 +0200 Subject: [PATCH] libcontainer/devices: add '//go:fix inline' directives This allows users to automaticaly migrate to the new location using `go fix`. It has some limitations, but can help smoothen the transition; for example, taking this file; ``` package main import ( "github.com/opencontainers/runc/libcontainer/devices" ) func main() { _, _ = devices.DeviceFromPath("a", "b") _, _ = devices.HostDevices() _, _ = devices.GetDevices("a") } ``` Running `go fix -mod=readonly ./...` will migrate the code; ``` package main import ( devices0 "github.com/moby/sys/devices" ) func main() { _, _ = devices0.DeviceFromPath("a", "b") _, _ = devices0.HostDevices() _, _ = devices0.GetDevices("a") } ``` updates b345c78dcae5ac0edad610fb6e71cb5db61f6842 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit ba83c7c7d7c5720c0606f021500e0e8f936e9894) Signed-off-by: Sebastiaan van Stijn --- libcontainer/devices/device_deprecated_unix.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libcontainer/devices/device_deprecated_unix.go b/libcontainer/devices/device_deprecated_unix.go index 6b9bf497302..f562b44c52a 100644 --- a/libcontainer/devices/device_deprecated_unix.go +++ b/libcontainer/devices/device_deprecated_unix.go @@ -17,6 +17,8 @@ import ( // // Deprecated: Use [devices.ErrNotADevice] instead. This package will be // removed in runc 1.6. +// +//go:fix inline var ErrNotADevice = devices.ErrNotADevice // DeviceFromPath takes the path to a device and its cgroup_permissions (which @@ -25,6 +27,8 @@ var ErrNotADevice = devices.ErrNotADevice // // Deprecated: Use [devices.DeviceFromPath] instead. This package will be // removed in runc 1.6. +// +//go:fix inline func DeviceFromPath(path, permissions string) (*config.Device, error) { return devices.DeviceFromPath(path, permissions) } @@ -33,6 +37,8 @@ func DeviceFromPath(path, permissions string) (*config.Device, error) { // // Deprecated: Use [devices.HostDevices] instead. This package will be // removed in runc 1.6. +// +//go:fix inline func HostDevices() ([]*config.Device, error) { return devices.HostDevices() } @@ -42,6 +48,8 @@ func HostDevices() ([]*config.Device, error) { // // Deprecated: Use [devices.GetDevices] instead. This package will be // removed in runc 1.6. +// +//go:fix inline func GetDevices(path string) ([]*config.Device, error) { return devices.GetDevices(path) }