Skip to content

Commit 731d728

Browse files
committed
Merge pull request #94 from mboersma/fix-home-load-units
fix(deisctl): Use $HOME/.deis/units, don't expand tilde (~) shortcut
2 parents d5d910b + 85b7922 commit 731d728

3 files changed

Lines changed: 2 additions & 14 deletions

File tree

backend/fleet/unit.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ import (
1010
"strings"
1111

1212
"github.com/coreos/fleet/unit"
13-
"github.com/deis/deisctl/utils"
1413
)
1514

1615
// path hierarchy for finding systemd service templates
1716
var templatePaths = []string{
1817
os.Getenv("DEISCTL_UNITS"),
19-
"~/.deis/units",
18+
os.Getenv("HOME") + "/.deis/units",
2019
"/var/lib/deis/units",
2120
}
2221

@@ -121,7 +120,6 @@ func readTemplate(component string) (out []byte, err error) {
121120
if p == "" {
122121
continue
123122
}
124-
p, _ := utils.ExpandUser(p)
125123
filename := path.Join(p, templateName)
126124
if _, err := os.Stat(filename); err == nil {
127125
templateFile = filename

cmd/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Options:
288288
fmt.Printf("Error: %v\n", err)
289289
os.Exit(2)
290290
}
291-
dir, _ := utils.ExpandUser(args["--path"].(string))
291+
dir := args["--path"].(string)
292292
// create the target dir if necessary
293293
if err := os.MkdirAll(dir, 0755); err != nil {
294294
return err

utils/utils.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"net"
1313
"os"
1414
"os/exec"
15-
"os/user"
1615
"path/filepath"
1716
"strings"
1817
"syscall"
@@ -258,15 +257,6 @@ func nLines(s string) int {
258257
return strings.Count(s, "\n")
259258
}
260259

261-
// ExpandUser replaces "~" in a string with the current user's home directory.
262-
func ExpandUser(path string) (string, error) {
263-
user, err := user.Current()
264-
if err != nil {
265-
return path, err
266-
}
267-
return strings.Replace(path, "~/", user.HomeDir+"/", 1), nil
268-
}
269-
270260
// DeisIfy returns a pretty-printed deis logo along with the corresponding message
271261
func DeisIfy(message string) string {
272262
circle := "\033[31m●"

0 commit comments

Comments
 (0)