Skip to content

Commit 3950958

Browse files
committed
feat(branding) - use executable-based values
In an effort to make rebranding the CLI app a bit easier, this changes all parsers, cmds, and settings to use a value based on the executable name rather than the hard-coded "deis" values. As things stand right now, the executable name built by `make` is still `deis`, so all online help via `deis help` will still refer to `deis`, `DEIS_PROFILE`, and `~/.deis/config.json`, and the default remote name is still `deis`. If on windows (where the executable is `deis.exe`), much of this is the same, except that the commands suggested in the online help refer to `deis.exe` rather than just `deis`. Renaming the executable to anything modifies all of the above to use the new exectuable name as the basis for the information presented.
1 parent 658410f commit 3950958

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1429
-1195
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
*.a
44
*.so
55

6+
# Editor temp files
7+
*.swp
8+
*~
9+
610
# Folders
711
_obj
812
_test

cmd/apps.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import (
1010
"github.com/teamhephy/controller-sdk-go/apps"
1111
"github.com/teamhephy/controller-sdk-go/config"
1212
"github.com/teamhephy/controller-sdk-go/domains"
13+
"github.com/teamhephy/workflow-cli/executable"
1314
"github.com/teamhephy/workflow-cli/pkg/git"
1415
"github.com/teamhephy/workflow-cli/pkg/logging"
1516
"github.com/teamhephy/workflow-cli/pkg/webbrowser"
1617
"github.com/teamhephy/workflow-cli/settings"
1718
)
1819

1920
// AppCreate creates an app.
20-
func (d *DeisCmd) AppCreate(id, buildpack, remote string, noRemote bool) error {
21+
func (d *HephyCmd) AppCreate(id, buildpack, remote string, noRemote bool) error {
2122
s, err := settings.Load(d.ConfigFile)
2223
if err != nil {
2324
return err
@@ -51,8 +52,8 @@ func (d *DeisCmd) AppCreate(id, buildpack, remote string, noRemote bool) error {
5152
if err = git.CreateRemote(git.DefaultCmd, s.Client.ControllerURL.Host, remote, app.ID); err != nil {
5253
if strings.Contains(err.Error(), fmt.Sprintf("fatal: remote %s already exists.", remote)) {
5354
msg := "A git remote with the name %s already exists. To overwrite this remote run:\n"
54-
msg += "deis git:remote --force --remote %s --app %s"
55-
return fmt.Errorf(msg, remote, remote, app.ID)
55+
msg += "%s git:remote --force --remote %s --app %s"
56+
return fmt.Errorf(msg, remote, executable.Name(), remote, app.ID)
5657
}
5758
return err
5859
}
@@ -61,14 +62,14 @@ func (d *DeisCmd) AppCreate(id, buildpack, remote string, noRemote bool) error {
6162
}
6263

6364
if noRemote {
64-
d.Printf("If you want to add a git remote for this app later, use `deis git:remote -a %s`\n", app.ID)
65+
d.Printf("If you want to add a git remote for this app later, use `%s git:remote -a %s`\n", executable.Name(), app.ID)
6566
}
6667

6768
return nil
6869
}
6970

70-
// AppsList lists apps on the Deis controller.
71-
func (d *DeisCmd) AppsList(results int) error {
71+
// AppsList lists apps on the Hephy controller.
72+
func (d *HephyCmd) AppsList(results int) error {
7273
s, err := settings.Load(d.ConfigFile)
7374

7475
if err != nil {
@@ -93,7 +94,7 @@ func (d *DeisCmd) AppsList(results int) error {
9394
}
9495

9596
// AppInfo prints info about app.
96-
func (d *DeisCmd) AppInfo(appID string) error {
97+
func (d *HephyCmd) AppInfo(appID string) error {
9798
s, appID, err := load(d.ConfigFile, appID)
9899

99100
if err != nil {
@@ -146,7 +147,7 @@ func (d *DeisCmd) AppInfo(appID string) error {
146147
}
147148

148149
// AppOpen opens an app in the default webbrowser.
149-
func (d *DeisCmd) AppOpen(appID string) error {
150+
func (d *HephyCmd) AppOpen(appID string) error {
150151
s, appID, err := load(d.ConfigFile, appID)
151152

152153
if err != nil {
@@ -170,7 +171,7 @@ func (d *DeisCmd) AppOpen(appID string) error {
170171
}
171172

172173
// AppLogs returns the logs from an app.
173-
func (d *DeisCmd) AppLogs(appID string, lines int) error {
174+
func (d *HephyCmd) AppLogs(appID string, lines int) error {
174175
s, appID, err := load(d.ConfigFile, appID)
175176

176177
if err != nil {
@@ -190,7 +191,7 @@ func (d *DeisCmd) AppLogs(appID string, lines int) error {
190191
}
191192

192193
// AppRun runs a one time command in the app.
193-
func (d *DeisCmd) AppRun(appID, command string) error {
194+
func (d *HephyCmd) AppRun(appID, command string) error {
194195
s, appID, err := load(d.ConfigFile, appID)
195196

196197
if err != nil {
@@ -215,7 +216,7 @@ func (d *DeisCmd) AppRun(appID, command string) error {
215216
}
216217

217218
// AppDestroy destroys an app.
218-
func (d *DeisCmd) AppDestroy(appID, confirm string) error {
219+
func (d *HephyCmd) AppDestroy(appID, confirm string) error {
219220
gitSession := false
220221

221222
s, err := settings.Load(d.ConfigFile)
@@ -265,7 +266,7 @@ func (d *DeisCmd) AppDestroy(appID, confirm string) error {
265266
}
266267

267268
// AppTransfer transfers app ownership to another user.
268-
func (d *DeisCmd) AppTransfer(appID, username string) error {
269+
func (d *HephyCmd) AppTransfer(appID, username string) error {
269270
s, appID, err := load(d.ConfigFile, appID)
270271

271272
if err != nil {
@@ -287,7 +288,7 @@ func (d *DeisCmd) AppTransfer(appID, username string) error {
287288
const noDomainAssignedMsg = "No domain assigned to %s"
288289

289290
// appURL grabs the first domain an app has and returns this.
290-
func (d *DeisCmd) appURL(s *settings.Settings, appID string) (string, error) {
291+
func (d *HephyCmd) appURL(s *settings.Settings, appID string) (string, error) {
291292
domains, _, err := domains.List(s.Client, appID, 1)
292293
if d.checkAPICompatibility(s.Client, err) != nil {
293294
return "", err

cmd/apps_test.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/arschles/assert"
1212

13+
"github.com/teamhephy/workflow-cli/executable"
1314
"github.com/teamhephy/workflow-cli/pkg/git"
1415
"github.com/teamhephy/workflow-cli/pkg/testutil"
1516
"github.com/teamhephy/workflow-cli/settings"
@@ -28,7 +29,7 @@ func TestAppsList(t *testing.T) {
2829
}
2930
defer server.Close()
3031
var b bytes.Buffer
31-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
32+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
3233

3334
server.Mux.HandleFunc("/v2/apps/", func(w http.ResponseWriter, r *http.Request) {
3435
testutil.SetHeaders(w)
@@ -77,7 +78,7 @@ func TestAppsListLimit(t *testing.T) {
7778
}
7879
defer server.Close()
7980
var b bytes.Buffer
80-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
81+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
8182

8283
server.Mux.HandleFunc("/v2/apps/", func(w http.ResponseWriter, r *http.Request) {
8384
testutil.SetHeaders(w)
@@ -115,7 +116,7 @@ func TestAppsInfo(t *testing.T) {
115116
}
116117
defer server.Close()
117118
var b bytes.Buffer
118-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
119+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
119120

120121
server.Mux.HandleFunc("/v2/apps/lorem-ipsum/", func(w http.ResponseWriter, r *http.Request) {
121122
testutil.SetHeaders(w)
@@ -224,7 +225,7 @@ func TestAppDestroy(t *testing.T) {
224225
}
225226
defer server.Close()
226227
var b bytes.Buffer
227-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
228+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
228229

229230
server.Mux.HandleFunc("/v2/apps/lorem-ipsum/", func(w http.ResponseWriter, r *http.Request) {
230231
testutil.SetHeaders(w)
@@ -257,7 +258,7 @@ func TestAppTransfer(t *testing.T) {
257258
}
258259
defer server.Close()
259260
var b bytes.Buffer
260-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
261+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
261262

262263
server.Mux.HandleFunc("/v2/apps/lorem-ipsum/", func(w http.ResponseWriter, r *http.Request) {
263264
testutil.SetHeaders(w)
@@ -327,14 +328,15 @@ func TestRemoteExists(t *testing.T) {
327328
assert.NoErr(t, os.Chdir(dir))
328329

329330
assert.NoErr(t, git.Init(git.DefaultCmd))
330-
assert.NoErr(t, git.CreateRemote(git.DefaultCmd, "localhost", "deis", "appname"))
331+
assert.NoErr(t, git.CreateRemote(git.DefaultCmd, "localhost", "hephy", "appname"))
331332

332333
var b bytes.Buffer
333-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
334+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
334335

335-
err = cmdr.AppCreate("foo", "", "deis", false)
336+
err = cmdr.AppCreate("foo", "", "hephy", false)
336337

337-
assert.Equal(t, err.Error(), `A git remote with the name deis already exists. To overwrite this remote run:
338-
deis git:remote --force --remote deis --app foo`,
339-
"output")
338+
expected := executable.Render(`A git remote with the name hephy already exists. To overwrite this remote run:
339+
{{.Name}} git:remote --force --remote hephy --app foo`)
340+
341+
assert.Equal(t, err.Error(), expected, "output")
340342
}

cmd/auth.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import (
66
"strings"
77
"syscall"
88

9-
deis "github.com/teamhephy/controller-sdk-go"
9+
hephy "github.com/teamhephy/controller-sdk-go"
1010
"github.com/teamhephy/controller-sdk-go/auth"
1111
"github.com/teamhephy/workflow-cli/settings"
1212
"golang.org/x/crypto/ssh/terminal"
1313
)
1414

15-
// Register creates a account on a Deis controller.
16-
func (d *DeisCmd) Register(controller string, username string, password string, email string,
15+
// Register creates a account on a Hephy controller.
16+
func (d *HephyCmd) Register(controller string, username string, password string, email string,
1717
sslVerify, login bool) error {
1818

19-
c, err := deis.New(sslVerify, controller, "")
19+
c, err := hephy.New(sslVerify, controller, "")
2020

2121
if err != nil {
2222
return err
@@ -83,7 +83,7 @@ func (d *DeisCmd) Register(controller string, username string, password string,
8383
return nil
8484
}
8585

86-
func (d *DeisCmd) doLogin(s settings.Settings, username, password string) error {
86+
func (d *HephyCmd) doLogin(s settings.Settings, username, password string) error {
8787
token, err := auth.Login(s.Client, username, password)
8888
if d.checkAPICompatibility(s.Client, err) != nil {
8989
return err
@@ -103,9 +103,9 @@ func (d *DeisCmd) doLogin(s settings.Settings, username, password string) error
103103
return nil
104104
}
105105

106-
// Login to a Deis controller.
107-
func (d *DeisCmd) Login(controller string, username string, password string, sslVerify bool) error {
108-
c, err := deis.New(sslVerify, controller, "")
106+
// Login to a Hephy controller.
107+
func (d *HephyCmd) Login(controller string, username string, password string, sslVerify bool) error {
108+
c, err := hephy.New(sslVerify, controller, "")
109109

110110
if err != nil {
111111
return err
@@ -137,8 +137,8 @@ func (d *DeisCmd) Login(controller string, username string, password string, ssl
137137
return d.doLogin(s, username, password)
138138
}
139139

140-
// Logout from a Deis controller.
141-
func (d *DeisCmd) Logout() error {
140+
// Logout from a Hephy controller.
141+
func (d *HephyCmd) Logout() error {
142142
if err := settings.Delete(d.ConfigFile); err != nil {
143143
return err
144144
}
@@ -148,7 +148,7 @@ func (d *DeisCmd) Logout() error {
148148
}
149149

150150
// Passwd changes a user's password.
151-
func (d *DeisCmd) Passwd(username, password, newPassword string) error {
151+
func (d *HephyCmd) Passwd(username, password, newPassword string) error {
152152
s, err := settings.Load(d.ConfigFile)
153153

154154
if err != nil {
@@ -197,7 +197,7 @@ func (d *DeisCmd) Passwd(username, password, newPassword string) error {
197197
}
198198

199199
// Cancel deletes a user's account.
200-
func (d *DeisCmd) Cancel(username, password string, yes bool) error {
200+
func (d *HephyCmd) Cancel(username, password string, yes bool) error {
201201
s, err := settings.Load(d.ConfigFile)
202202

203203
if err != nil {
@@ -241,7 +241,7 @@ func (d *DeisCmd) Cancel(username, password string, yes bool) error {
241241
}
242242

243243
err = auth.Delete(s.Client, username)
244-
if err == deis.ErrConflict {
244+
if err == hephy.ErrConflict {
245245
return fmt.Errorf("%s still has applications associated with it. Transfer ownership or delete them first", username)
246246
} else if d.checkAPICompatibility(s.Client, err) != nil {
247247
return err
@@ -260,7 +260,7 @@ func (d *DeisCmd) Cancel(username, password string, yes bool) error {
260260

261261
// Whoami prints the logged in user. If all is true, it fetches info from the controller to know
262262
// more about the user.
263-
func (d *DeisCmd) Whoami(all bool) error {
263+
func (d *HephyCmd) Whoami(all bool) error {
264264
s, err := settings.Load(d.ConfigFile)
265265

266266
if err != nil {
@@ -280,7 +280,7 @@ func (d *DeisCmd) Whoami(all bool) error {
280280
}
281281

282282
// Regenerate regenenerates a user's token.
283-
func (d *DeisCmd) Regenerate(username string, all bool) error {
283+
func (d *HephyCmd) Regenerate(username string, all bool) error {
284284
s, err := settings.Load(d.ConfigFile)
285285

286286
if err != nil {

cmd/auth_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestRegister(t *testing.T) {
1717
}
1818
defer server.Close()
1919
var b bytes.Buffer
20-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
20+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
2121

2222
server.Mux.HandleFunc("/v2/", func(w http.ResponseWriter, r *http.Request) {
2323
testutil.SetHeaders(w)
@@ -65,7 +65,7 @@ func TestLogin(t *testing.T) {
6565
}
6666
defer server.Close()
6767
var b bytes.Buffer
68-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
68+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
6969

7070
server.Mux.HandleFunc("/v2/", func(w http.ResponseWriter, r *http.Request) {
7171
testutil.SetHeaders(w)
@@ -92,7 +92,7 @@ func TestLogout(t *testing.T) {
9292
}
9393
defer server.Close()
9494
var b bytes.Buffer
95-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
95+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
9696

9797
err = cmdr.Logout()
9898
assert.NoErr(t, err)
@@ -108,7 +108,7 @@ func TestPasswd(t *testing.T) {
108108
}
109109
defer server.Close()
110110
var b bytes.Buffer
111-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
111+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
112112

113113
server.Mux.HandleFunc("/v2/auth/passwd/", func(w http.ResponseWriter, r *http.Request) {
114114
testutil.SetHeaders(w)
@@ -134,7 +134,7 @@ func TestCancel(t *testing.T) {
134134
}
135135
defer server.Close()
136136
var b bytes.Buffer
137-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
137+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
138138

139139
server.Mux.HandleFunc("/v2/", func(w http.ResponseWriter, r *http.Request) {
140140
testutil.SetHeaders(w)
@@ -167,7 +167,7 @@ func TestWhoami(t *testing.T) {
167167
}
168168
defer server.Close()
169169
var b bytes.Buffer
170-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
170+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
171171

172172
server.Mux.HandleFunc("/v2/auth/whoami/", func(w http.ResponseWriter, r *http.Request) {
173173
testutil.SetHeaders(w)
@@ -201,7 +201,7 @@ func TestWhoamiAll(t *testing.T) {
201201
}
202202
defer server.Close()
203203
var b bytes.Buffer
204-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
204+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
205205

206206
server.Mux.HandleFunc("/v2/auth/whoami/", func(w http.ResponseWriter, r *http.Request) {
207207
testutil.SetHeaders(w)
@@ -245,7 +245,7 @@ func TestRegenerate(t *testing.T) {
245245
}
246246
defer server.Close()
247247
var b bytes.Buffer
248-
cmdr := DeisCmd{WOut: &b, ConfigFile: cf}
248+
cmdr := HephyCmd{WOut: &b, ConfigFile: cf}
249249

250250
server.Mux.HandleFunc("/v2/auth/tokens/", func(w http.ResponseWriter, r *http.Request) {
251251
testutil.SetHeaders(w)

cmd/autoscale.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
// AutoscaleList tells the informations about app's autoscale status
9-
func (d *DeisCmd) AutoscaleList(appID string) error {
9+
func (d *HephyCmd) AutoscaleList(appID string) error {
1010
s, appID, err := load(d.ConfigFile, appID)
1111

1212
if err != nil {
@@ -33,7 +33,7 @@ func (d *DeisCmd) AutoscaleList(appID string) error {
3333
}
3434

3535
// AutoscaleSet sets autoscale options for the app.
36-
func (d *DeisCmd) AutoscaleSet(appID string, processType string, min int, max int, CPUPercent int) error {
36+
func (d *HephyCmd) AutoscaleSet(appID string, processType string, min int, max int, CPUPercent int) error {
3737
s, appID, err := load(d.ConfigFile, appID)
3838

3939
if err != nil {
@@ -64,7 +64,7 @@ func (d *DeisCmd) AutoscaleSet(appID string, processType string, min int, max in
6464
}
6565

6666
// AutoscaleUnset removes autoscale for the app.
67-
func (d *DeisCmd) AutoscaleUnset(appID string, processType string) error {
67+
func (d *HephyCmd) AutoscaleUnset(appID string, processType string) error {
6868
s, appID, err := load(d.ConfigFile, appID)
6969

7070
if err != nil {

0 commit comments

Comments
 (0)