diff --git a/plugin/backend_linux_test.go b/plugin/backend_linux_test.go index bb4e7172f5..59e8a37a65 100644 --- a/plugin/backend_linux_test.go +++ b/plugin/backend_linux_test.go @@ -32,7 +32,7 @@ func TestAtomicRemoveAllAlreadyExists(t *testing.T) { } defer os.RemoveAll(dir) // just try to make sure this gets cleaned up - if err := os.MkdirAll(dir+"-removing", 0755); err != nil { + if err := os.MkdirAll(dir+"-removing", 0o755); err != nil { t.Fatal(err) } defer os.RemoveAll(dir + "-removing") @@ -63,7 +63,7 @@ func TestAtomicRemoveAllNotExist(t *testing.T) { // create the removing dir, but not the "real" one foo := filepath.Join(dir, "foo") removing := dir + "-removing" - if err := os.MkdirAll(removing, 0755); err != nil { + if err := os.MkdirAll(removing, 0o755); err != nil { t.Fatal(err) } diff --git a/plugin/manager.go b/plugin/manager.go index 7e03ed7a40..67f2131c3e 100644 --- a/plugin/manager.go +++ b/plugin/manager.go @@ -29,8 +29,10 @@ import ( "github.com/sirupsen/logrus" ) -const configFileName = "config.json" -const rootFSFileName = "rootfs" +const ( + configFileName = "config.json" + rootFSFileName = "rootfs" +) var validFullID = regexp.MustCompile(`^([a-f0-9]{64})$`) @@ -95,7 +97,7 @@ func NewManager(config ManagerConfig) (*Manager, error) { config: config, } for _, dirName := range []string{manager.config.Root, manager.config.ExecRoot, manager.tmpDir()} { - if err := os.MkdirAll(dirName, 0700); err != nil { + if err := os.MkdirAll(dirName, 0o700); err != nil { return nil, errors.Wrapf(err, "failed to mkdir %v", dirName) } } @@ -227,7 +229,7 @@ func (pm *Manager) reload() error { // todo: restore } } - if err := os.MkdirAll(propRoot, 0755); err != nil { + if err := os.MkdirAll(propRoot, 0o755); err != nil { log.G(context.TODO()).Errorf("failed to create PropagatedMount directory at %s: %v", propRoot, err) } } @@ -272,7 +274,7 @@ func (pm *Manager) save(p *v2.Plugin) error { if err != nil { return errors.Wrap(err, "failed to marshal plugin json") } - if err := ioutils.AtomicWriteFile(filepath.Join(pm.config.Root, p.GetID(), configFileName), pluginJSON, 0600); err != nil { + if err := ioutils.AtomicWriteFile(filepath.Join(pm.config.Root, p.GetID(), configFileName), pluginJSON, 0o600); err != nil { return errors.Wrap(err, "failed to write atomically plugin json") } return nil diff --git a/plugin/manager_linux.go b/plugin/manager_linux.go index a7cd10b374..1820e3fc72 100644 --- a/plugin/manager_linux.go +++ b/plugin/manager_linux.go @@ -45,7 +45,7 @@ func (pm *Manager) enable(p *v2.Plugin, c *controller, force bool) error { if p.PluginObj.Config.PropagatedMount != "" { propRoot = filepath.Join(filepath.Dir(p.Rootfs), "propagated-mount") - if err := os.MkdirAll(propRoot, 0755); err != nil { + if err := os.MkdirAll(propRoot, 0o755); err != nil { log.G(context.TODO()).Errorf("failed to create PropagatedMount directory at %s: %v", propRoot, err) } @@ -321,7 +321,7 @@ func (pm *Manager) createPlugin(name string, configDigest, manifestDigest digest } pdir := filepath.Join(pm.config.Root, p.PluginObj.ID) - if err := os.MkdirAll(pdir, 0700); err != nil { + if err := os.MkdirAll(pdir, 0o700); err != nil { return nil, errors.Wrapf(err, "failed to mkdir %v", pdir) } diff --git a/plugin/manager_linux_test.go b/plugin/manager_linux_test.go index 6224cc018a..67e9114e5b 100644 --- a/plugin/manager_linux_test.go +++ b/plugin/manager_linux_test.go @@ -55,7 +55,7 @@ func TestManagerWithPluginMounts(t *testing.T) { // Create a mount to simulate a plugin that has created it's own mounts p2Mount := filepath.Join(p2.Rootfs, "testmount") - if err := os.MkdirAll(p2Mount, 0755); err != nil { + if err := os.MkdirAll(p2Mount, 0o755); err != nil { t.Fatal(err) } if err := mount.Mount("tmpfs", p2Mount, "tmpfs", ""); err != nil { @@ -73,7 +73,7 @@ func TestManagerWithPluginMounts(t *testing.T) { func newTestPlugin(t *testing.T, name, cap, root string) *v2.Plugin { id := stringid.GenerateRandomID() rootfs := filepath.Join(root, id) - if err := os.MkdirAll(rootfs, 0755); err != nil { + if err := os.MkdirAll(rootfs, 0o755); err != nil { t.Fatal(err) } @@ -151,6 +151,7 @@ func (e *executorWithRunning) Create(id string, spec specs.Spec, stdout, stderr func (e *executorWithRunning) IsRunning(id string) (bool, error) { return true, nil } + func (e *executorWithRunning) Restore(id string, stdout, stderr io.WriteCloser) (bool, error) { return true, nil } @@ -211,7 +212,7 @@ func TestPluginAlreadyRunningOnStartup(t *testing.T) { root := filepath.Join(root, desc) config.Root = filepath.Join(root, "manager") - if err := os.MkdirAll(filepath.Join(config.Root, p.GetID()), 0755); err != nil { + if err := os.MkdirAll(filepath.Join(config.Root, p.GetID()), 0o755); err != nil { t.Fatal(err) } @@ -244,7 +245,7 @@ func TestPluginAlreadyRunningOnStartup(t *testing.T) { } func listenTestPlugin(sockAddr string, exit chan struct{}) (net.Listener, error) { - if err := os.MkdirAll(filepath.Dir(sockAddr), 0755); err != nil { + if err := os.MkdirAll(filepath.Dir(sockAddr), 0o755); err != nil { return nil, err } l, err := net.Listen("unix", sockAddr) diff --git a/plugin/v2/plugin_linux.go b/plugin/v2/plugin_linux.go index 0c86b88fc3..82f973ffc9 100644 --- a/plugin/v2/plugin_linux.go +++ b/plugin/v2/plugin_linux.go @@ -27,7 +27,7 @@ func (p *Plugin) InitSpec(execRoot string) (*specs.Spec, error) { } execRoot = filepath.Join(execRoot, p.PluginObj.ID) - if err := os.MkdirAll(execRoot, 0700); err != nil { + if err := os.MkdirAll(execRoot, 0o700); err != nil { return nil, errors.WithStack(err) }