Skip to content

Commit

Permalink
Merge pull request #48 from qiniu/develop
Browse files Browse the repository at this point in the history
Release v2.0.0
  • Loading branch information
nowenL authored Dec 20, 2016
2 parents 63799b0 + 9f3f735 commit 56cddb3
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# vNext

# Release 2.0.0
- 新增app授权和撤销授权功能
- Service SCALING 状态拆分为 SCALING-UP SCALING-DOWN
- 日志搜索结果添加CollectedAtNano字段
- 添加 GetWebProxy 方法

# Release 1.2.0
- 添加禁用/启用AP端口的API,并在查看/搜索AP的API返回的端口信息中返回端口的启用状态(启用/禁用)。
Expand Down
4 changes: 2 additions & 2 deletions kirksdk/account_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion kirksdk/kirksdk.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package kirksdk

const Version = "1.2.0"
const Version = "2.0.0"
12 changes: 12 additions & 0 deletions kirksdk/qcos_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ type QcosClient interface {

// DELETE /v3/configservices/<namespace>
DeleteConfigServiceSpec(ctx context.Context, namespace string) (err error)

// POST /v3/webproxy
GetWebProxy(ctx context.Context, args GetWebProxyArgs) (ret WebProxyInfo, err error)
}

const (
Expand Down Expand Up @@ -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"`
}
7 changes: 7 additions & 0 deletions kirksdk/qcos_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions kirksdk/qcos_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 56cddb3

Please sign in to comment.