From ede8a86ec1e35ecd1ecf4b05efb1f8ce6cb3c97d Mon Sep 17 00:00:00 2001 From: root Date: Sat, 3 Oct 2020 01:59:33 +0000 Subject: [PATCH] Convert root path to absolute path on create command Signed-off-by: Amim Knabben --- main.go | 3 +++ utils.go | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/main.go b/main.go index fd1ad5ff1..1c443639e 100644 --- a/main.go +++ b/main.go @@ -141,6 +141,9 @@ func main() { fatal(err) } } + if err := reviseRootDir(context); err != nil { + return err + } return logs.ConfigureLogging(createLogConfig(context)) } diff --git a/utils.go b/utils.go index c687a4782..8b31be03f 100644 --- a/utils.go +++ b/utils.go @@ -92,6 +92,21 @@ func revisePidFile(context *cli.Context) error { return context.Set("pid-file", pidFile) } +// reviseRootDir convert the root to absolute path +func reviseRootDir(context *cli.Context) error { + root := context.GlobalString("root") + if root == "" { + return nil + } + + root, err := filepath.Abs(root) + if err != nil { + return err + } + + return context.GlobalSet("root", root) +} + // parseBoolOrAuto returns (nil, nil) if s is empty or "auto" func parseBoolOrAuto(s string) (*bool, error) { if s == "" || strings.ToLower(s) == "auto" {