From c695cff02c2b6b830e301eacabef88cb96ea7754 Mon Sep 17 00:00:00 2001 From: "longwenlu@gmail.com" Date: Thu, 15 Dec 2016 14:13:07 +0800 Subject: [PATCH 1/5] QCOS-3373 Add GetWebProxy --- CHANGELOG.md | 1 + kirksdk/qcos_api.go | 12 ++++++++++++ kirksdk/qcos_client.go | 7 +++++++ kirksdk/qcos_client_test.go | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bf76ab..d539ad3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # vNext - Service SCALING 状态拆分为 SCALING-UP SCALING-DOWN - 日志搜索结果添加CollectedAtNano字段 +- 添加 GetWebProxy 方法 # Release 1.2.0 - 添加禁用/启用AP端口的API,并在查看/搜索AP的API返回的端口信息中返回端口的启用状态(启用/禁用)。 diff --git a/kirksdk/qcos_api.go b/kirksdk/qcos_api.go index 1360f91..1abcbf3 100644 --- a/kirksdk/qcos_api.go +++ b/kirksdk/qcos_api.go @@ -333,6 +333,9 @@ type QcosClient interface { // DELETE /v3/configservices/ DeleteConfigServiceSpec(ctx context.Context, namespace string) (err error) + + // POST /v3/webproxy + GetWebProxy(ctx context.Context, args GetWebProxyArgs) (ret WebProxyInfo, err error) } const ( @@ -931,3 +934,12 @@ type UpdateConfigServiceSpecArgs struct { Vars map[string]interface{} `json:"vars"` Listvars []map[string]interface{} `json:"listvars"` } + +type GetWebProxyArgs struct { + Backend string `json:"backend"` +} + +type WebProxyInfo struct { + Backend string `json:"backend"` + OneTimeURL string `json:"oneTimeUrl"` +} diff --git a/kirksdk/qcos_client.go b/kirksdk/qcos_client.go index 8514548..cb0e498 100644 --- a/kirksdk/qcos_client.go +++ b/kirksdk/qcos_client.go @@ -1319,6 +1319,13 @@ func (p *qcosClientImp) DeleteConfigServiceSpec(ctx context.Context, namespace s return } +// POST /v3/webproxy +func (p *qcosClientImp) GetWebProxy(ctx context.Context, args GetWebProxyArgs) (ret WebProxyInfo, err error) { + url := fmt.Sprintf("%s/v3/webproxy", p.host) + err = p.client.CallWithJson(ctx, &ret, "POST", url, args) + return +} + func (p *qcosClientImp) wait4StackRunning(stackName string, timeout time.Duration) (err error) { if stackName == "" { stackName = DefaultStack diff --git a/kirksdk/qcos_client_test.go b/kirksdk/qcos_client_test.go index f733264..6781389 100644 --- a/kirksdk/qcos_client_test.go +++ b/kirksdk/qcos_client_test.go @@ -645,3 +645,36 @@ func TestUpdateJob(t *testing.T) { err := client.UpdateJob(context.TODO(), "default", args) assert.NoError(t, err) } + +func TestGetWebproxy(t *testing.T) { + expectedUrl := "/v3/webproxy" + expectedMethod := "POST" + expectedBody := `{"backend":"10.128.0.1:8080"}` + returnBody := `{ + "backend": "10.128.0.1:8080", + "oneTimeUrl": "http://dummy.com" +}` + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, expectedUrl, r.URL.Path) + assert.Equal(t, expectedMethod, r.Method) + body, err := ioutil.ReadAll(r.Body) + assert.NoError(t, err) + assert.Equal(t, expectedBody, string(body)) + fmt.Fprintln(w, returnBody) + })) + defer ts.Close() + + client := NewQcosClient(QcosConfig{ + Host: ts.URL, + }) + + args := GetWebProxyArgs{ + Backend: "10.128.0.1:8080", + } + + webproxy, err := client.GetWebProxy(context.TODO(), args) + assert.NoError(t, err) + assert.Equal(t, "10.128.0.1:8080", webproxy.Backend) + assert.Equal(t, "http://dummy.com", webproxy.OneTimeURL) +} From 8ed244e0c72c4bfd72eeb7bc61d1c0f910800f03 Mon Sep 17 00:00:00 2001 From: pqx Date: Thu, 15 Dec 2016 18:18:33 +0800 Subject: [PATCH 2/5] QCOS-3363 modify change log --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f8fd29..fbe1d19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # vNext - Service SCALING 状态拆分为 SCALING-UP SCALING-DOWN +# Release 1.2.1 +- 新增app授权和撤销授权功能 + # Release 1.2.0 - 添加禁用/启用AP端口的API,并在查看/搜索AP的API返回的端口信息中返回端口的启用状态(启用/禁用)。 - 查看服务时,给出与该服务关联的AP端口信息。 From 264baa41c6d03ccb23d6cd52c89e54808a4bc5ad Mon Sep 17 00:00:00 2001 From: pqx Date: Thu, 15 Dec 2016 18:39:29 +0800 Subject: [PATCH 3/5] QCOS-3363 fix changelog format --- CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbe1d19..a620628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,6 @@ # vNext -- Service SCALING 状态拆分为 SCALING-UP SCALING-DOWN - -# Release 1.2.1 - 新增app授权和撤销授权功能 +- Service SCALING 状态拆分为 SCALING-UP SCALING-DOWN # Release 1.2.0 - 添加禁用/启用AP端口的API,并在查看/搜索AP的API返回的端口信息中返回端口的启用状态(启用/禁用)。 From b0395be4b9dac77a34946c9ccc616eb301d6bc21 Mon Sep 17 00:00:00 2001 From: pqx Date: Tue, 20 Dec 2016 10:40:05 +0800 Subject: [PATCH 4/5] QCOS-3398 grant ==> grants --- kirksdk/account_client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kirksdk/account_client.go b/kirksdk/account_client.go index 73b8b7a..02d6d72 100644 --- a/kirksdk/account_client.go +++ b/kirksdk/account_client.go @@ -138,13 +138,13 @@ func (p *accountClientImp) UpdateAlertMethod(ctx context.Context, appURI string, } func (p *accountClientImp) CreateAppGrant(ctx context.Context, appURI, username string) (err error) { - url := fmt.Sprintf("%s%s/apps/%s/grant/%s", p.host, appVersionPrefix, appURI, username) + url := fmt.Sprintf("%s%s/apps/%s/grants/%s", p.host, appVersionPrefix, appURI, username) err = p.client.Call(ctx, nil, "PUT", url) return } func (p *accountClientImp) DeleteAppGrant(ctx context.Context, appURI, username string) (err error) { - url := fmt.Sprintf("%s%s/apps/%s/grant/%s", p.host, appVersionPrefix, appURI, username) + url := fmt.Sprintf("%s%s/apps/%s/grants/%s", p.host, appVersionPrefix, appURI, username) err = p.client.Call(ctx, nil, "DELETE", url) return } From cd3a6e82d8539f343902824540f5daafb913fddf Mon Sep 17 00:00:00 2001 From: "longwenlu@gmail.com" Date: Tue, 20 Dec 2016 17:07:31 +0800 Subject: [PATCH 5/5] QCOS-0 Prepare for release v2.0.0 --- CHANGELOG.md | 2 ++ kirksdk/kirksdk.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a68902..1f0aa51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # vNext + +# Release 2.0.0 - 新增app授权和撤销授权功能 - Service SCALING 状态拆分为 SCALING-UP SCALING-DOWN - 日志搜索结果添加CollectedAtNano字段 diff --git a/kirksdk/kirksdk.go b/kirksdk/kirksdk.go index aaa479b..a4cf6fd 100644 --- a/kirksdk/kirksdk.go +++ b/kirksdk/kirksdk.go @@ -1,3 +1,3 @@ package kirksdk -const Version = "1.2.0" +const Version = "2.0.0"