From 85b79224663428ac463e1e4ecc8b39f95a35a29d Mon Sep 17 00:00:00 2001 From: Matt Boersma Date: Wed, 24 Sep 2014 12:37:17 -0600 Subject: [PATCH] fix(deisctl): Use $HOME/.deis/units, don't expand tilde (~) shortcut The go func `user.Current()` returns error now that we build as a static binary. Don't bother expanding ~ to $HOME, just use $HOME. --- backend/fleet/unit.go | 4 +--- cmd/cmd.go | 2 +- utils/utils.go | 10 ---------- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/backend/fleet/unit.go b/backend/fleet/unit.go index 58d29004b4..99ab7af1b3 100644 --- a/backend/fleet/unit.go +++ b/backend/fleet/unit.go @@ -10,13 +10,12 @@ import ( "strings" "github.com/coreos/fleet/unit" - "github.com/deis/deisctl/utils" ) // path hierarchy for finding systemd service templates var templatePaths = []string{ os.Getenv("DEISCTL_UNITS"), - "~/.deis/units", + os.Getenv("HOME") + "/.deis/units", "/var/lib/deis/units", } @@ -121,7 +120,6 @@ func readTemplate(component string) (out []byte, err error) { if p == "" { continue } - p, _ := utils.ExpandUser(p) filename := path.Join(p, templateName) if _, err := os.Stat(filename); err == nil { templateFile = filename diff --git a/cmd/cmd.go b/cmd/cmd.go index ead16f251a..36f0e9ccf5 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -288,7 +288,7 @@ Options: fmt.Printf("Error: %v\n", err) os.Exit(2) } - dir, _ := utils.ExpandUser(args["--path"].(string)) + dir := args["--path"].(string) // create the target dir if necessary if err := os.MkdirAll(dir, 0755); err != nil { return err diff --git a/utils/utils.go b/utils/utils.go index 8322108cbb..4dc2b92982 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -12,7 +12,6 @@ import ( "net" "os" "os/exec" - "os/user" "path/filepath" "strings" "syscall" @@ -258,15 +257,6 @@ func nLines(s string) int { return strings.Count(s, "\n") } -// ExpandUser replaces "~" in a string with the current user's home directory. -func ExpandUser(path string) (string, error) { - user, err := user.Current() - if err != nil { - return path, err - } - return strings.Replace(path, "~/", user.HomeDir+"/", 1), nil -} - // DeisIfy returns a pretty-printed deis logo along with the corresponding message func DeisIfy(message string) string { circle := "\033[31m●"