list, utils: remove redundant code

The value of root is already an absolute path since commit
ede8a86ec1, so it does not make sense to call filepath.Abs()
again.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2022-02-10 18:30:46 -08:00
parent 2436322fef
commit 36786c361a
2 changed files with 2 additions and 12 deletions
+1 -6
View File
@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"syscall"
"text/tabwriter"
"time"
@@ -116,11 +115,7 @@ func getContainers(context *cli.Context) ([]containerState, error) {
return nil, err
}
root := context.GlobalString("root")
absRoot, err := filepath.Abs(root)
if err != nil {
return nil, err
}
list, err := os.ReadDir(absRoot)
list, err := os.ReadDir(root)
if err != nil {
fatal(err)
}
+1 -6
View File
@@ -26,12 +26,7 @@ var errEmptyID = errors.New("container id cannot be empty")
// loadFactory returns the configured factory instance for execing containers.
func loadFactory(context *cli.Context) (libcontainer.Factory, error) {
root := context.GlobalString("root")
abs, err := filepath.Abs(root)
if err != nil {
return nil, err
}
return libcontainer.New(abs)
return libcontainer.New(root)
}
// getContainer returns the specified container instance by loading it from state