Skip to content

Commit ede8a86

Browse files
rootknabben
root
authored andcommitted
Convert root path to absolute path on create command
Signed-off-by: Amim Knabben <[email protected]>
1 parent 09ddc63 commit ede8a86

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

main.go

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ func main() {
141141
fatal(err)
142142
}
143143
}
144+
if err := reviseRootDir(context); err != nil {
145+
return err
146+
}
144147
return logs.ConfigureLogging(createLogConfig(context))
145148
}
146149

utils.go

+15
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ func revisePidFile(context *cli.Context) error {
9292
return context.Set("pid-file", pidFile)
9393
}
9494

95+
// reviseRootDir convert the root to absolute path
96+
func reviseRootDir(context *cli.Context) error {
97+
root := context.GlobalString("root")
98+
if root == "" {
99+
return nil
100+
}
101+
102+
root, err := filepath.Abs(root)
103+
if err != nil {
104+
return err
105+
}
106+
107+
return context.GlobalSet("root", root)
108+
}
109+
95110
// parseBoolOrAuto returns (nil, nil) if s is empty or "auto"
96111
func parseBoolOrAuto(s string) (*bool, error) {
97112
if s == "" || strings.ToLower(s) == "auto" {

0 commit comments

Comments
 (0)