Skip to content

Commit 253ba4d

Browse files
authored
Merge pull request #21 from jianxiaoguo/main
fix(resource): fixup update resource options
2 parents b3d7b4b + 0d519f4 commit 253ba4d

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

cmd/resources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func maxNum(tempArray ...int) int {
269269
// parseParams transfer params to map
270270
func parseParams(params []string) (map[string]interface{}, error) {
271271
paramsMap := make(map[string]interface{})
272-
regex := regexp.MustCompile(`^([A-z_]+[A-z0-9_]*)((\.){1}([A-z0-9_]+))*=([\s\S]*)$`)
272+
regex := regexp.MustCompile(`^([A-z_]+[A-z0-9_]*[\.{1}[A-z0-9_]+]*)=([\s\S]*)$`)
273273
for _, param := range params {
274274
if regex.MatchString(param) {
275275
captures := regex.FindStringSubmatch(param)

cmd/resources_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,16 @@ func TestResourcePut(t *testing.T) {
152152
cmdr := DryccCmd{WOut: &b, ConfigFile: cf}
153153

154154
server.Mux.HandleFunc("/v2/apps/example-go/resources/mysql/", func(w http.ResponseWriter, r *http.Request) {
155-
testutil.AssertBody(t, api.Resource{Plan: "mysql:5.7"}, r)
155+
paras := make(map[string]interface{}, 1)
156+
paras["para1.para2"] = "v1"
157+
testutil.AssertBody(t, api.Resource{Plan: "mysql:5.7", Options: paras}, r)
156158
testutil.SetHeaders(w)
157159
w.WriteHeader(http.StatusCreated)
158160
// Body isn't used by CLI, so it isn't set.
159161
w.Write([]byte("{}"))
160162
})
161163

162-
err = cmdr.ResourcePut("example-go", "mysql:5.7", "mysql", nil)
164+
err = cmdr.ResourcePut("example-go", "mysql:5.7", "mysql", []string{"para1.para2=v1"})
163165
assert.NoErr(t, err)
164166

165167
assert.Equal(t, testutil.StripProgress(b.String()), "Updating mysql to example-go... done\n", "output")

0 commit comments

Comments
 (0)