diff --git a/plugin/manager.go b/plugin/manager.go index e0ac6e85fb127..f144e8208b4d3 100644 --- a/plugin/manager.go +++ b/plugin/manager.go @@ -107,14 +107,10 @@ func NewManager(config ManagerConfig) (*Manager, error) { manager := &Manager{ config: config, } - if err := os.MkdirAll(manager.config.Root, 0700); err != nil { - return nil, errors.Wrapf(err, "failed to mkdir %v", manager.config.Root) - } - if err := os.MkdirAll(manager.config.ExecRoot, 0700); err != nil { - return nil, errors.Wrapf(err, "failed to mkdir %v", manager.config.ExecRoot) - } - if err := os.MkdirAll(manager.tmpDir(), 0700); err != nil { - return nil, errors.Wrapf(err, "failed to mkdir %v", manager.tmpDir()) + for _, dirName := range []string{manager.config.Root, manager.config.ExecRoot, manager.tmpDir()} { + if err := os.MkdirAll(dirName, 0700); err != nil { + return nil, errors.Wrapf(err, "failed to mkdir %v", dirName) + } } if err := setupRoot(manager.config.Root); err != nil {