Skip to content

Commit baf1f27

Browse files
committed
ref(client): deis open uses the controller hostname for the app hostname
1 parent 47ec729 commit baf1f27

3 files changed

Lines changed: 42 additions & 32 deletions

File tree

client/controller/api/apps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type App struct {
66
ID string `json:"id"`
77
Owner string `json:"owner"`
88
Updated string `json:"updated"`
9-
URL string `json:"url"`
9+
URL string `json:"-"`
1010
UUID string `json:"uuid"`
1111
}
1212

client/controller/models/apps/apps.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ func List(c *client.Client, results int) ([]api.App, int, error) {
2323
return []api.App{}, -1, err
2424
}
2525

26+
for name, app := range apps {
27+
// Add in app URL based on controller hostname, port included
28+
app.URL = fmt.Sprintf("%s.%s", app.ID, c.ControllerURL.Host)
29+
apps[name] = app
30+
}
31+
2632
return apps, count, nil
2733
}
2834

@@ -51,6 +57,9 @@ func New(c *client.Client, id string) (api.App, error) {
5157
return api.App{}, err
5258
}
5359

60+
// Add in app URL based on controller hostname, port included
61+
app.URL = fmt.Sprintf("%s.%s", app.ID, c.ControllerURL.Host)
62+
5463
return app, nil
5564
}
5665

@@ -70,6 +79,9 @@ func Get(c *client.Client, appID string) (api.App, error) {
7079
return api.App{}, err
7180
}
7281

82+
// Add in app URL based on controller hostname, port included
83+
app.URL = fmt.Sprintf("%s.%s", app.ID, c.ControllerURL.Host)
84+
7385
return app, nil
7486
}
7587

client/controller/models/apps/apps_test.go

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const appFixture string = `
2121
"owner": "test",
2222
"structure": {},
2323
"updated": "2014-01-01T00:00:00UTC",
24-
"url": "example-go.example.com",
2524
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
2625
}`
2726

@@ -37,7 +36,6 @@ const appsFixture string = `
3736
"owner": "test",
3837
"structure": {},
3938
"updated": "2014-01-01T00:00:00UTC",
40-
"url": "example-go.example.com",
4139
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
4240
}
4341
]
@@ -157,15 +155,6 @@ func (f *fakeHTTPServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
157155
func TestAppsCreate(t *testing.T) {
158156
t.Parallel()
159157

160-
expected := api.App{
161-
ID: "example-go",
162-
Created: "2014-01-01T00:00:00UTC",
163-
Owner: "test",
164-
Updated: "2014-01-01T00:00:00UTC",
165-
URL: "example-go.example.com",
166-
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
167-
}
168-
169158
handler := fakeHTTPServer{createID: false, createWithoutID: false}
170159
server := httptest.NewServer(&handler)
171160
defer server.Close()
@@ -176,6 +165,15 @@ func TestAppsCreate(t *testing.T) {
176165
t.Fatal(err)
177166
}
178167

168+
expected := api.App{
169+
ID: "example-go",
170+
Created: "2014-01-01T00:00:00UTC",
171+
Owner: "test",
172+
Updated: "2014-01-01T00:00:00UTC",
173+
URL: fmt.Sprintf("example-go.%s", u.Host),
174+
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
175+
}
176+
179177
httpClient := client.CreateHTTPClient(false)
180178

181179
client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}
@@ -196,15 +194,6 @@ func TestAppsCreate(t *testing.T) {
196194
func TestAppsGet(t *testing.T) {
197195
t.Parallel()
198196

199-
expected := api.App{
200-
ID: "example-go",
201-
Created: "2014-01-01T00:00:00UTC",
202-
Owner: "test",
203-
Updated: "2014-01-01T00:00:00UTC",
204-
URL: "example-go.example.com",
205-
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
206-
}
207-
208197
handler := fakeHTTPServer{}
209198
server := httptest.NewServer(&handler)
210199
defer server.Close()
@@ -215,6 +204,15 @@ func TestAppsGet(t *testing.T) {
215204
t.Fatal(err)
216205
}
217206

207+
expected := api.App{
208+
ID: "example-go",
209+
Created: "2014-01-01T00:00:00UTC",
210+
Owner: "test",
211+
Updated: "2014-01-01T00:00:00UTC",
212+
URL: fmt.Sprintf("example-go.%s", u.Host),
213+
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
214+
}
215+
218216
httpClient := client.CreateHTTPClient(false)
219217

220218
client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}
@@ -288,17 +286,6 @@ func TestAppsRun(t *testing.T) {
288286
func TestAppsList(t *testing.T) {
289287
t.Parallel()
290288

291-
expected := []api.App{
292-
{
293-
ID: "example-go",
294-
Created: "2014-01-01T00:00:00UTC",
295-
Owner: "test",
296-
Updated: "2014-01-01T00:00:00UTC",
297-
URL: "example-go.example.com",
298-
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
299-
},
300-
}
301-
302289
handler := fakeHTTPServer{}
303290
server := httptest.NewServer(&handler)
304291
defer server.Close()
@@ -309,6 +296,17 @@ func TestAppsList(t *testing.T) {
309296
t.Fatal(err)
310297
}
311298

299+
expected := []api.App{
300+
{
301+
ID: "example-go",
302+
Created: "2014-01-01T00:00:00UTC",
303+
Owner: "test",
304+
Updated: "2014-01-01T00:00:00UTC",
305+
URL: fmt.Sprintf("example-go.%s", u.Host),
306+
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
307+
},
308+
}
309+
312310
httpClient := client.CreateHTTPClient(false)
313311

314312
client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}

0 commit comments

Comments
 (0)