mirror of
https://github.com/mudler/luet.git
synced 2025-09-18 16:32:16 +00:00
Review configuration file parsing logic
Luet support now these priorities on read configuration file: - command line option (if available) - $PWD/.luet.yaml - $HOME/.luet.yaml - /etc/luet/luet.yaml
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"syscall"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -30,3 +32,17 @@ func Exec(cmd string, args []string, env []string) error {
|
||||
}
|
||||
return syscall.Exec(path, args, env)
|
||||
}
|
||||
|
||||
func GetHomeDir() (ans string) {
|
||||
// os/user doesn't work in from scratch environments
|
||||
u, err := user.Current()
|
||||
if err == nil {
|
||||
ans = u.HomeDir
|
||||
} else {
|
||||
ans = ""
|
||||
}
|
||||
if os.Getenv("HOME") != "" {
|
||||
ans = os.Getenv("HOME")
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
Reference in New Issue
Block a user