Skip to content

Commit f3fdd9e

Browse files
committed
chore(config): add ptype tag
1 parent 75bd5eb commit f3fdd9e

3 files changed

Lines changed: 29 additions & 16 deletions

File tree

api/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import (
66
"text/template"
77
)
88

9+
// ConfigTags is the key, value for tag
10+
type ConfigTags map[string]interface{}
11+
912
// ConfigValues is the key, value for env
1013
type ConfigValues map[string]interface{}
1114

@@ -40,7 +43,7 @@ type Config struct {
4043
// Healthcheck is map of healthchecks for each process that the application uses.
4144
Healthcheck map[string]*Healthchecks `json:"healthcheck,omitempty"`
4245
// Tags restrict applications to run on k8s nodes with that label.
43-
Tags map[string]interface{} `json:"tags,omitempty"`
46+
Tags map[string]ConfigTags `json:"tags,omitempty"`
4447
// Registry is a key-value pair to provide authentication for container registries.
4548
// The key is the username and the value is the password.
4649
Registry map[string]interface{} `json:"registry,omitempty"`

config/config_test.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ const configFixture string = `
2929
"web": "std1.xlarge.c1m1"
3030
},
3131
"tags": {
32-
"test": "tests"
32+
"web": {
33+
"test": "tests"
34+
}
3335
},
3436
"registry": {
3537
"username": "bob"
@@ -55,8 +57,8 @@ const configUnsetFixture string = `
5557
}
5658
`
5759

58-
const configSetExpected string = `{"values":{"FOO":"bar","TEST":"testing"},"typed_values":{"web":{"PORT":"9000"}},"limits":{"web":"std1.xlarge.c1m1"},"tags":{"test":"tests"},"registry":{"username":"bob"}}`
59-
const configUnsetExpected string = `{"values":{"FOO":null,"TEST":null},"typed_values":{"web":{"PORT":null}},"limits":{"web":null},"tags":{"test":null},"registry":{"username":null}}`
60+
const configSetExpected string = `{"values":{"FOO":"bar","TEST":"testing"},"typed_values":{"web":{"PORT":"9000"}},"limits":{"web":"std1.xlarge.c1m1"},"tags":{"web":{"test":"tests"}},"registry":{"username":"bob"}}`
61+
const configUnsetExpected string = `{"values":{"FOO":null,"TEST":null},"typed_values":{"web":{"PORT":null}},"limits":{"web":null},"tags":{"web":{"test":null}},"registry":{"username":null}}`
6062

6163
type fakeHTTPServer struct{}
6264

@@ -140,8 +142,10 @@ func TestConfigSet(t *testing.T) {
140142
Limits: map[string]interface{}{
141143
"web": "std1.xlarge.c1m1",
142144
},
143-
Tags: map[string]interface{}{
144-
"test": "tests",
145+
Tags: map[string]api.ConfigTags{
146+
"web": {
147+
"test": "tests",
148+
},
145149
},
146150
Registry: map[string]interface{}{
147151
"username": "bob",
@@ -162,8 +166,10 @@ func TestConfigSet(t *testing.T) {
162166
Limits: map[string]interface{}{
163167
"web": "std1.xlarge.c1m1",
164168
},
165-
Tags: map[string]interface{}{
166-
"test": "tests",
169+
Tags: map[string]api.ConfigTags{
170+
"web": {
171+
"test": "tests",
172+
},
167173
},
168174
Registry: map[string]interface{}{
169175
"username": "bob",
@@ -201,7 +207,7 @@ func TestConfigUnset(t *testing.T) {
201207
"web": {"PORT": nil},
202208
},
203209
Limits: map[string]interface{}{},
204-
Tags: map[string]interface{}{},
210+
Tags: map[string]api.ConfigTags{},
205211
Registry: map[string]interface{}{},
206212
Created: "2014-01-01T00:00:00UTC",
207213
Updated: "2014-01-01T00:00:00UTC",
@@ -219,8 +225,8 @@ func TestConfigUnset(t *testing.T) {
219225
Limits: map[string]interface{}{
220226
"web": nil,
221227
},
222-
Tags: map[string]interface{}{
223-
"test": nil,
228+
Tags: map[string]api.ConfigTags{
229+
"web": {"test": nil},
224230
},
225231
Registry: map[string]interface{}{
226232
"username": nil,
@@ -263,8 +269,8 @@ func TestConfigList(t *testing.T) {
263269
Limits: map[string]interface{}{
264270
"web": "std1.xlarge.c1m1",
265271
},
266-
Tags: map[string]interface{}{
267-
"test": "tests",
272+
Tags: map[string]api.ConfigTags{
273+
"web": {"test": "tests"},
268274
},
269275
Registry: map[string]interface{}{
270276
"username": "bob",

hooks/hooks_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ const configFixture string = `
3030
"web": "std1.xlarge.c1m1"
3131
},
3232
"tags": {
33-
"test": "tests"
33+
"web": {
34+
"test": "tests"
35+
}
3436
},
3537
"registry": {
3638
"username": "bob"
@@ -162,8 +164,10 @@ func TestConfigHook(t *testing.T) {
162164
Limits: map[string]interface{}{
163165
"web": "std1.xlarge.c1m1",
164166
},
165-
Tags: map[string]interface{}{
166-
"test": "tests",
167+
Tags: map[string]api.ConfigTags{
168+
"web": {
169+
"test": "tests",
170+
},
167171
},
168172
Registry: map[string]interface{}{
169173
"username": "bob",

0 commit comments

Comments
 (0)