Nitpick plugin/manager.go: use loop to create directories
Instead of duplicating the same if condition per plugin manager directory,
use one if condition and a for-loop.
@@ -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)
+ 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 := 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())
}
if err := setupRoot(manager.config.Root); err != nil {
