Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
fix(deisctl): Use $HOME/.deis/units, don't expand tilde (~) shortcut
Browse files Browse the repository at this point in the history
The go func `user.Current()` returns error now that we build as a
static binary. Don't bother expanding ~ to $HOME, just use $HOME.
  • Loading branch information
mboersma committed Sep 24, 2014
1 parent a41e22c commit 85b7922
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
4 changes: 1 addition & 3 deletions backend/fleet/unit.go
Expand Up @@ -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",
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd.go
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions utils/utils.go
Expand Up @@ -12,7 +12,6 @@ import (
"net"
"os"
"os/exec"
"os/user"
"path/filepath"
"strings"
"syscall"
Expand Down Expand Up @@ -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●"
Expand Down

0 comments on commit 85b7922

Please sign in to comment.