Ver Fonte

plugin: format code with gofumpt

Formatting the code with https://github.com/mvdan/gofumpt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn há 3 anos atrás
pai
commit
83b2daca6a

+ 2 - 2
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)
 	}
 

+ 7 - 5
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

+ 2 - 2
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)
 	}
 

+ 5 - 4
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)

+ 1 - 1
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)
 	}