Commit 02a757ed authored by Addshore's avatar Addshore 🏄
Browse files

dev: When sudo is used, detect correct user home

parent dfe89277
......@@ -45,9 +45,26 @@ func mwddUserDirectory() string {
return ciDir + ".mwcli/mwdd"
}
currentUser, _ := user.Current()
currentUser, err := user.Current()
if err != nil {
panic(err)
}
// If we are root, check to see if we can detect sudo being used
if currentUser.Uid == "0" {
sudoUID := os.Getenv("SUDO_UID")
if sudoUID == "" {
panic("detected sudo but no SUDO_UID")
}
currentUser, err = user.LookupId(sudoUID)
if err != nil {
panic(err)
}
}
projectDirectory := currentUser.HomeDir + string(os.PathSeparator) + ".mwcli/mwdd"
return projectDirectory
}
/*Directory the directory containing the development environment*/
......@@ -71,11 +88,6 @@ func (m MWDD) EnsureReady() {
m.Env().EnsureExists()
}
/*EnsureHostsFile Make sure that a bunch of hosts that we will use are in the hosts file*/
func (m MWDD) EnsureHostsFile() {
//TODO this will differ per serviceset though...
}
// DockerComposeCommand results in something like: `docker-compose <automatic project stuff> <command> <commandArguments>`
type DockerComposeCommand struct {
Command string
......@@ -215,4 +227,4 @@ func (m MWDD) RmVolumes(dcVolumes []string, options exec.HandlerOptions) {
// TODO execIt?
// TODO run?
// TODO runDetatched?
// TODO logsTail?
\ No newline at end of file
// TODO logsTail?
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment