Skip to content

Commit ced0c44

Browse files
committed
Merge pull request #45 from helgi/registry
feat(registry): add support for setting private registry information per application
2 parents 8868adc + 0e57b5f commit ced0c44

2 files changed

Lines changed: 38 additions & 20 deletions

File tree

api/config.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ type ConfigUnset struct {
1212

1313
// Config is the structure of an app's config.
1414
type Config struct {
15-
Owner string `json:"owner,omitempty"`
16-
App string `json:"app,omitempty"`
17-
Values map[string]interface{} `json:"values,omitempty"`
18-
Memory map[string]interface{} `json:"memory,omitempty"`
19-
CPU map[string]interface{} `json:"cpu,omitempty"`
20-
Tags map[string]interface{} `json:"tags,omitempty"`
21-
Created string `json:"created,omitempty"`
22-
Updated string `json:"updated,omitempty"`
23-
UUID string `json:"uuid,omitempty"`
15+
Owner string `json:"owner,omitempty"`
16+
App string `json:"app,omitempty"`
17+
Values map[string]interface{} `json:"values,omitempty"`
18+
Memory map[string]interface{} `json:"memory,omitempty"`
19+
CPU map[string]interface{} `json:"cpu,omitempty"`
20+
Tags map[string]interface{} `json:"tags,omitempty"`
21+
Registry map[string]interface{} `json:"registry,omitempty"`
22+
Created string `json:"created,omitempty"`
23+
Updated string `json:"updated,omitempty"`
24+
UUID string `json:"uuid,omitempty"`
2425
}

models/config/config_test.go

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const configFixture string = `
3131
"tags": {
3232
"test": "tests"
3333
},
34+
"registry": {
35+
"username": "bob"
36+
},
3437
"created": "2014-01-01T00:00:00UTC",
3538
"updated": "2014-01-01T00:00:00UTC",
3639
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
@@ -45,14 +48,15 @@ const configUnsetFixture string = `
4548
"memory": {},
4649
"cpu": {},
4750
"tags": {},
51+
"registry": {},
4852
"created": "2014-01-01T00:00:00UTC",
4953
"updated": "2014-01-01T00:00:00UTC",
5054
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
5155
}
5256
`
5357

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

5761
type fakeHTTPServer struct{}
5862

@@ -144,6 +148,9 @@ func TestConfigSet(t *testing.T) {
144148
Tags: map[string]interface{}{
145149
"test": "tests",
146150
},
151+
Registry: map[string]interface{}{
152+
"username": "bob",
153+
},
147154
Created: "2014-01-01T00:00:00UTC",
148155
Updated: "2014-01-01T00:00:00UTC",
149156
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
@@ -163,6 +170,9 @@ func TestConfigSet(t *testing.T) {
163170
Tags: map[string]interface{}{
164171
"test": "tests",
165172
},
173+
Registry: map[string]interface{}{
174+
"username": "bob",
175+
},
166176
}
167177

168178
actual, err := Set(&client, "example-go", configVars)
@@ -194,15 +204,16 @@ func TestConfigUnset(t *testing.T) {
194204
client := client.Client{HTTPClient: httpClient, ControllerURL: *u, Token: "abc"}
195205

196206
expected := api.Config{
197-
Owner: "test",
198-
App: "unset-test",
199-
Values: map[string]interface{}{},
200-
Memory: map[string]interface{}{},
201-
CPU: map[string]interface{}{},
202-
Tags: map[string]interface{}{},
203-
Created: "2014-01-01T00:00:00UTC",
204-
Updated: "2014-01-01T00:00:00UTC",
205-
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
207+
Owner: "test",
208+
App: "unset-test",
209+
Values: map[string]interface{}{},
210+
Memory: map[string]interface{}{},
211+
CPU: map[string]interface{}{},
212+
Tags: map[string]interface{}{},
213+
Registry: map[string]interface{}{},
214+
Created: "2014-01-01T00:00:00UTC",
215+
Updated: "2014-01-01T00:00:00UTC",
216+
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
206217
}
207218

208219
configVars := api.Config{
@@ -219,6 +230,9 @@ func TestConfigUnset(t *testing.T) {
219230
Tags: map[string]interface{}{
220231
"test": nil,
221232
},
233+
Registry: map[string]interface{}{
234+
"username": nil,
235+
},
222236
}
223237

224238
actual, err := Set(&client, "unset-test", configVars)
@@ -265,6 +279,9 @@ func TestConfigList(t *testing.T) {
265279
Tags: map[string]interface{}{
266280
"test": "tests",
267281
},
282+
Registry: map[string]interface{}{
283+
"username": "bob",
284+
},
268285
Created: "2014-01-01T00:00:00UTC",
269286
Updated: "2014-01-01T00:00:00UTC",
270287
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",

0 commit comments

Comments
 (0)