Skip to content

Commit dd3c53b

Browse files
committed
ref(routable): move routable from config to appsettings
1 parent d1ad818 commit dd3c53b

4 files changed

Lines changed: 25 additions & 25 deletions

File tree

api/appsettings.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,12 @@ type AppSettings struct {
1414
// It changes every time the application settings is changed and cannot be updated.
1515
UUID string `json:"uuid,omitempty"`
1616
// Maintenance determines if the application is taken down for maintenance or not.
17-
Maintenance *bool `json:"maintenance"`
17+
Maintenance *bool `json:"maintenance,omitempty"`
18+
// Routable determines if the application should be exposed by the router.
19+
Routable *bool `json:"routable,omitempty"`
20+
}
21+
22+
func NewRoutable() *bool {
23+
b := true
24+
return &b
1825
}

api/config.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ type Config struct {
4444
// UUID is a unique string reflecting the configuration in its current state.
4545
// It changes every time the configuration is changed and cannot be updated.
4646
UUID string `json:"uuid,omitempty"`
47-
// Routable determines if the application should be exposed by the router.
48-
Routable *bool `json:"routable,omitempty"`
49-
}
50-
51-
func NewRoutable() *bool {
52-
b := true
53-
return &b
5447
}
5548

5649
// ConfigHookRequest defines the request for configuration from the config hook.

appsettings/appsettings_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const appSettingsFixture string = `
1717
"owner": "test",
1818
"app": "example-go",
1919
"maintenance": true,
20+
"routable": true,
2021
"created": "2014-01-01T00:00:00UTC",
2122
"updated": "2014-01-01T00:00:00UTC",
2223
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
@@ -28,14 +29,15 @@ const appSettingsUnsetFixture string = `
2829
"owner": "test",
2930
"app": "unset-test",
3031
"maintenance": true,
32+
"routable": true,
3133
"created": "2014-01-01T00:00:00UTC",
3234
"updated": "2014-01-01T00:00:00UTC",
3335
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
3436
}
3537
`
3638

37-
const appSettingsSetExpected string = `{"maintenance":true}`
38-
const appSettingsUnsetExpected string = `{"maintenance":true}`
39+
const appSettingsSetExpected string = `{"maintenance":true,"routable":true}`
40+
const appSettingsUnsetExpected string = `{"maintenance":true,"routable":true}`
3941

4042
var trueVar = true
4143

@@ -122,6 +124,7 @@ func TestAppSettingsSet(t *testing.T) {
122124
expected := api.AppSettings{
123125
Owner: "test",
124126
App: "example-go",
127+
Routable: api.NewRoutable(),
125128
Maintenance: &trueVar,
126129
Created: "2014-01-01T00:00:00UTC",
127130
Updated: "2014-01-01T00:00:00UTC",
@@ -130,6 +133,7 @@ func TestAppSettingsSet(t *testing.T) {
130133

131134
appSettingsVars := api.AppSettings{
132135
Maintenance: &trueVar,
136+
Routable: api.NewRoutable(),
133137
}
134138

135139
actual, err := Set(deis, "example-go", appSettingsVars)
@@ -159,13 +163,15 @@ func TestAppSettingsUnset(t *testing.T) {
159163
Owner: "test",
160164
App: "unset-test",
161165
Maintenance: &trueVar,
166+
Routable: api.NewRoutable(),
162167
Created: "2014-01-01T00:00:00UTC",
163168
Updated: "2014-01-01T00:00:00UTC",
164169
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
165170
}
166171

167172
appSettingsVars := api.AppSettings{
168173
Maintenance: &trueVar,
174+
Routable: api.NewRoutable(),
169175
}
170176

171177
actual, err := Set(deis, "unset-test", appSettingsVars)
@@ -195,6 +201,7 @@ func TestAppSettingsList(t *testing.T) {
195201
Owner: "test",
196202
App: "example-go",
197203
Maintenance: &trueVar,
204+
Routable: api.NewRoutable(),
198205
Created: "2014-01-01T00:00:00UTC",
199206
Updated: "2014-01-01T00:00:00UTC",
200207
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",

config/config_test.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const configFixture string = `
3232
"registry": {
3333
"username": "bob"
3434
},
35-
"routable": true,
3635
"created": "2014-01-01T00:00:00UTC",
3736
"updated": "2014-01-01T00:00:00UTC",
3837
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
@@ -48,15 +47,14 @@ const configUnsetFixture string = `
4847
"cpu": {},
4948
"tags": {},
5049
"registry": {},
51-
"routable": true,
5250
"created": "2014-01-01T00:00:00UTC",
5351
"updated": "2014-01-01T00:00:00UTC",
5452
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
5553
}
5654
`
5755

58-
const configSetExpected string = `{"values":{"FOO":"bar","TEST":"testing"},"memory":{"web":"1G"},"cpu":{"web":"1000"},"tags":{"test":"tests"},"registry":{"username":"bob"},"routable":true}`
59-
const configUnsetExpected string = `{"values":{"FOO":null,"TEST":null},"memory":{"web":null},"cpu":{"web":null},"tags":{"test":null},"registry":{"username":null},"routable":true}`
56+
const configSetExpected string = `{"values":{"FOO":"bar","TEST":"testing"},"memory":{"web":"1G"},"cpu":{"web":"1000"},"tags":{"test":"tests"},"registry":{"username":"bob"}}`
57+
const configUnsetExpected string = `{"values":{"FOO":null,"TEST":null},"memory":{"web":null},"cpu":{"web":null},"tags":{"test":null},"registry":{"username":null}}`
6058

6159
type fakeHTTPServer struct{}
6260

@@ -146,10 +144,9 @@ func TestConfigSet(t *testing.T) {
146144
Registry: map[string]interface{}{
147145
"username": "bob",
148146
},
149-
Routable: api.NewRoutable(),
150-
Created: "2014-01-01T00:00:00UTC",
151-
Updated: "2014-01-01T00:00:00UTC",
152-
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
147+
Created: "2014-01-01T00:00:00UTC",
148+
Updated: "2014-01-01T00:00:00UTC",
149+
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
153150
}
154151

155152
configVars := api.Config{
@@ -169,7 +166,6 @@ func TestConfigSet(t *testing.T) {
169166
Registry: map[string]interface{}{
170167
"username": "bob",
171168
},
172-
Routable: api.NewRoutable(),
173169
}
174170

175171
actual, err := Set(deis, "example-go", configVars)
@@ -203,7 +199,6 @@ func TestConfigUnset(t *testing.T) {
203199
CPU: map[string]interface{}{},
204200
Tags: map[string]interface{}{},
205201
Registry: map[string]interface{}{},
206-
Routable: api.NewRoutable(),
207202
Created: "2014-01-01T00:00:00UTC",
208203
Updated: "2014-01-01T00:00:00UTC",
209204
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
@@ -226,7 +221,6 @@ func TestConfigUnset(t *testing.T) {
226221
Registry: map[string]interface{}{
227222
"username": nil,
228223
},
229-
Routable: api.NewRoutable(),
230224
}
231225

232226
actual, err := Set(deis, "unset-test", configVars)
@@ -271,10 +265,9 @@ func TestConfigList(t *testing.T) {
271265
Registry: map[string]interface{}{
272266
"username": "bob",
273267
},
274-
Routable: api.NewRoutable(),
275-
Created: "2014-01-01T00:00:00UTC",
276-
Updated: "2014-01-01T00:00:00UTC",
277-
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
268+
Created: "2014-01-01T00:00:00UTC",
269+
Updated: "2014-01-01T00:00:00UTC",
270+
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
278271
}
279272

280273
actual, err := List(deis, "example-go")

0 commit comments

Comments
 (0)