Skip to content

Commit 578495a

Browse files
jianxiaoguoduanhongyi
authored andcommitted
chore(controller-sdk-go): set config add merge param (#48)
1 parent 910603c commit 578495a

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

config/config.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ func List(c *drycc.Client, app string, version int) (api.Config, error) {
4141
// Calling Set() with an empty api.Config will return a drycc.ErrConflict.
4242
// Trying to unset a key that does not exist returns a drycc.ErrUnprocessable.
4343
// Trying to set a tag that is not a label in the kubernetes cluster will return a drycc.ErrTagNotFound.
44-
func Set(c *drycc.Client, app string, config api.Config) (api.Config, error) {
44+
func Set(c *drycc.Client, app string, config api.Config, merge bool) (api.Config, error) {
4545
body, err := json.Marshal(config)
4646
if err != nil {
4747
return api.Config{}, err
4848
}
4949

50-
u := fmt.Sprintf("/v2/apps/%s/config/", app)
51-
50+
u := fmt.Sprintf("/v2/apps/%s/config/?merge=%v", app, merge)
5251
res, reqErr := c.Request("POST", u, body)
5352
if reqErr != nil {
5453
return api.Config{}, reqErr

config/config_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func TestConfigSet(t *testing.T) {
275275
},
276276
}
277277

278-
actual, err := Set(drycc, "example-go", configVars)
278+
actual, err := Set(drycc, "example-go", configVars, true)
279279
if err != nil {
280280
t.Error(err)
281281
}
@@ -332,7 +332,7 @@ func TestConfigUnset(t *testing.T) {
332332
},
333333
}
334334

335-
actual, err := Set(drycc, "unset-test", configVars)
335+
actual, err := Set(drycc, "unset-test", configVars, true)
336336
if err != nil {
337337
t.Error(err)
338338
}
@@ -449,7 +449,7 @@ func TestConfigRefs(t *testing.T) {
449449
},
450450
}
451451

452-
actual, err := Set(drycc, "setrefs-test", configVars)
452+
actual, err := Set(drycc, "setrefs-test", configVars, true)
453453
if err != nil {
454454
t.Error(err)
455455
}

0 commit comments

Comments
 (0)