Skip to content

Commit a442675

Browse files
committed
ref(client): update and document unit file search paths
deisctl looks for unit files in these directories, in this order: - the $DEISCTL_UNITS environment variable, if set - $HOME/.deis/units - /var/lib/deis/units
1 parent 1da62d8 commit a442675

3 files changed

Lines changed: 20 additions & 17 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ curl -sSL http://deis.io/deisctl/install.sh | sudo sh
1111
```
1212

1313
The installer puts `deisctl` in */usr/local/bin* and downloads current Deis unit files
14-
to *~/.deisctl* one time.
14+
to */var/lib/deis/units* one time.
1515

1616
To change installation options, save the installer directly from one of these links:
1717

@@ -115,7 +115,7 @@ The `deisctl` tool provides a number of other commands, including:
115115
* `deisctl install <component>` - install a single platform component
116116
* `deisctl uninstall <component>` - uninstall a single platform component
117117
* `deisctl scale <component>=<num>` - scale a component to the target number of units
118-
* `deisctl refresh-units` - download latest unit files to ~/.deisctl
118+
* `deisctl refresh-units` - download latest unit files
119119

120120
## Usage Examples
121121

client/unit.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import (
1414
)
1515

1616
// path hierarchy for finding systemd service templates
17-
var rootPaths = []string{"~/.deisctl/units", "/var/lib/deis/units"}
17+
var templatePaths = []string{
18+
os.Getenv("DEISCTL_UNITS"),
19+
"~/.deis/units",
20+
"/var/lib/deis/units",
21+
}
1822

1923
// Units returns a list of units filtered by target
2024
func (c *FleetClient) Units(target string) (units []string, err error) {
@@ -109,22 +113,16 @@ func readTemplate(component string) (out []byte, err error) {
109113
templateName := "deis-" + component + ".service"
110114
var templateFile string
111115

112-
// first look for unit files in GOPATH
113-
if os.Getenv("GOPATH") != "" {
114-
filename := path.Join(os.Getenv("GOPATH"),
115-
path.Join("src", "github.com", "deis", "deisctl", "units", templateName))
116+
// look in $DEISCTL_UNITS env var, then the local and global root paths
117+
for _, p := range templatePaths {
118+
if p == "" {
119+
continue
120+
}
121+
p, _ := ExpandUser(p)
122+
filename := path.Join(p, templateName)
116123
if _, err := os.Stat(filename); err == nil {
117124
templateFile = filename
118-
}
119-
} else {
120-
// otherwise look in rootPaths hierarchy
121-
for _, rootPath := range rootPaths {
122-
rootPath, _ := ExpandUser(rootPath)
123-
filename := path.Join(rootPath, templateName)
124-
if _, err := os.Stat(filename); err == nil {
125-
templateFile = filename
126-
break
127-
}
125+
break
128126
}
129127
}
130128

cmd/cmd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ func Update() error {
259259
func RefreshUnits() error {
260260
usage := `Refreshes local unit files from the master repository.
261261
262+
deisctl looks for unit files in these directories, in this order:
263+
- the $DEISCTL_UNITS environment variable, if set
264+
- $HOME/.deis/units
265+
- /var/lib/deis/units
266+
262267
Usage:
263268
deisctl refresh-units [-p <target>]
264269

0 commit comments

Comments
 (0)