Skip to content

Commit

Permalink
Merge pull request #39 from qiniu/develop
Browse files Browse the repository at this point in the history
QCOS-0 Merge develop into master for 1.2.0 release
  • Loading branch information
xiaoq08 committed Dec 6, 2016
2 parents 0acaa61 + dba0e59 commit 53cc577
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md merge=union
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# vNext

# Release 1.2.0
- 添加禁用/启用AP端口的API,并在查看/搜索AP的API返回的端口信息中返回端口的启用状态(启用/禁用)。
- 查看服务时,给出与该服务关联的AP端口信息。
- 为 Service 以及 Job 增加 Confs 域
- 增加 ConfigService 相关 V3 接口
- 为 index 列取tag 接口增加排序,分页和时间参数

# Release 1.1.0
- AccountClient 相关 API 使用 appd V3 接口
Expand Down
2 changes: 1 addition & 1 deletion kirksdk/account_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (p *accountClientImp) GetQcosClient(ctx context.Context, appURI string) (cl
keyChan <- result
}()

// Get qocos end point
// Get qcos end point
go func() {
var result endpointResult
appInfos, err := p.ListApps(ctx)
Expand Down
4 changes: 3 additions & 1 deletion kirksdk/index_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type IndexAuthClient interface {
type IndexClient interface {
ListRepo(ctx context.Context, username string) (repos []*Repo, err error)
ListRepoTags(ctx context.Context, username, repo string) (tags []*Tag, err error)
ListRepoTagsPage(ctx context.Context, username, repo string, start, size int) (tags []*Tag, err error)
GetImageConfig(ctx context.Context, username, repo, reference string) (res *ImageConfig, err error)
DeleteRepoTag(ctx context.Context, username, repo, reference string) error
CreateTagFromRepo(ctx context.Context, username, repo, tag string, from *ImageSpec) (result *ImageSpec, err error)
Expand All @@ -36,7 +37,8 @@ type Repo struct {
}

type Tag struct {
Name string `json:"name"`
Name string `json:"name"`
Created time.Time `json:"created"`
}

type ImageConfig struct {
Expand Down
6 changes: 6 additions & 0 deletions kirksdk/index_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func (p *indexClientImp) ListRepoTags(ctx context.Context, username, repo string
return
}

func (p *indexClientImp) ListRepoTagsPage(ctx context.Context, username, repo string, start, size int) (tags []*Tag, err error) {
err = p.client.Call(ctx, &tags, "GET", fmt.Sprintf("%s/api/%s/%s/tags?start=%d&size=%d",
p.host, username, repo, start, size))
return
}

func (p *indexClientImp) GetImageConfig(ctx context.Context, username, repo, reference string) (res *ImageConfig, err error) {
err = p.client.Call(ctx, &res, "GET", fmt.Sprintf("%s/api/%s/%s/repo/%s", p.host, username, repo, reference))
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.1.0"
const Version = "1.2.0"
35 changes: 35 additions & 0 deletions kirksdk/qcos_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,22 @@ type QcosClient interface {
DeleteApPortRange(
ctx context.Context, apid string, fromPort string, toPort string) (err error)

// POST /v3/aps/<apid>/<port>/enable
EnableApPort(
ctx context.Context, apid string, port string) (err error)

// POST /v3/aps/<apid>/<port>/disable
DisableApPort(
ctx context.Context, apid string, port string) (err error)

// POST /v3/aps/<apid>/portrange/<from>/<to>/enable
EnableApPortRange(
ctx context.Context, apid string, fromPort string, toPort string) (err error)

// POST /v3/aps/<apid>/portrange/<from>/<to>/disable
DisableApPortRange(
ctx context.Context, apid string, fromPort string, toPort string) (err error)

// DELETE /v3/aps/<apid>
DeleteAp(ctx context.Context, apid string) (err error)

Expand Down Expand Up @@ -314,6 +330,9 @@ type QcosClient interface {

// POST /v3/configservices/<namespace>
UpdateConfigServiceSpec(ctx context.Context, namespace string, args UpdateConfigServiceSpecArgs) (err error)

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

const (
Expand All @@ -340,6 +359,7 @@ const (
ApTypePublicIPStr = "PUBLIC_IP"
ApTypePrivateIPStr = "INTERNAL_IP"
ApTypeDomainStr = "DOMAIN"
ApTypeOutwardIPStr = "OUTWARD_IP"
)

type Status string
Expand Down Expand Up @@ -399,6 +419,7 @@ type ServiceInfo struct {
UpdatingProgress int `json:"updatingProgress"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
ApPorts []ServiceApPort `json:"apPorts"`
}

type ServiceExportInfo struct {
Expand Down Expand Up @@ -543,6 +564,19 @@ type StartContainerExecArgs struct {
Mode string `json:"mode"`
}

// AP ports related to a service.
type ServiceApPort struct {
ApID string `json:"apId"`
Type string `json:"type"`
IP string `json:"ip,omitempty"`
Domain string `json:"domain,omitempty"`
UserDomains []string `json:"userDomains,omitempty"`
FrontendPort string `json:"frontendPort"`
BackendPort string `json:"backendPort"`
Proto string `json:"proto"`
Enabled bool `json:"enabled"`
}

type CreateApArgs struct {
Type string `json:"type"`
Provider string `json:"provider"`
Expand Down Expand Up @@ -602,6 +636,7 @@ type ApPortInfo struct {
SessionTmoSec int `json:"sessionTimeoutSec"`
ProxyOpts ApProxyOpts `json:"proxyOptions"`
HealthCheckOpts ApHealthCheckOpts `json:"healthCheck"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Backends []struct {
Expand Down
39 changes: 39 additions & 0 deletions kirksdk/qcos_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,38 @@ func (p *qcosClientImp) DeleteApPortRange(
return
}

// POST /v3/aps/<apid>/<port>/enable
func (p *qcosClientImp) EnableApPort(
ctx context.Context, apid string, port string) (err error) {
url := fmt.Sprintf("%s/v3/aps/%s/%s/enable", p.host, apid, port)
err = p.client.CallWithJson(ctx, nil, "POST", url, nil)
return
}

// POST /v3/aps/<apid>/<port>/disable
func (p *qcosClientImp) DisableApPort(
ctx context.Context, apid string, port string) (err error) {
url := fmt.Sprintf("%s/v3/aps/%s/%s/disable", p.host, apid, port)
err = p.client.CallWithJson(ctx, nil, "POST", url, nil)
return
}

// POST /v3/aps/<apid>/portrange/<from>/<to>/enable
func (p *qcosClientImp) EnableApPortRange(
ctx context.Context, apid string, fromPort string, toPort string) (err error) {
url := fmt.Sprintf("%s/v3/aps/%s/portrange/%s/%s/enable", p.host, apid, fromPort, toPort)
err = p.client.CallWithJson(ctx, nil, "POST", url, nil)
return
}

// POST /v3/aps/<apid>/portrange/<from>/<to>/disable
func (p *qcosClientImp) DisableApPortRange(
ctx context.Context, apid string, fromPort string, toPort string) (err error) {
url := fmt.Sprintf("%s/v3/aps/%s/portrange/%s/%s/disable", p.host, apid, fromPort, toPort)
err = p.client.CallWithJson(ctx, nil, "POST", url, nil)
return
}

// GET /v3/aps/<apid>/<port>/healthcheck
func (p *qcosClientImp) GetHealthcheck(ctx context.Context, apid string, port string) (ret map[string]string, err error) {
url := fmt.Sprintf("%s/v3/aps/%s/%s/healthcheck", p.host, apid, port)
Expand Down Expand Up @@ -1280,6 +1312,13 @@ func (p *qcosClientImp) UpdateConfigServiceSpec(ctx context.Context, namespace s
return
}

// DELETE /v3/configservices/<namespace>
func (p *qcosClientImp) DeleteConfigServiceSpec(ctx context.Context, namespace string) (err error) {
url := fmt.Sprintf("%s/v3/configservices/%s", p.host, namespace)
err = p.client.Call(ctx, nil, "DELETE", url)
return
}

func (p *qcosClientImp) wait4StackRunning(stackName string, timeout time.Duration) (err error) {
if stackName == "" {
stackName = DefaultStack
Expand Down
24 changes: 23 additions & 1 deletion kirksdk/qcos_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,18 @@ func TestServicesInspect(t *testing.T) {
Name: "v2",
},
},
ApPorts: []ServiceApPort{
ServiceApPort{
ApID: "1000001",
Type: "DOMAIN",
Domain: "abcd1234",
UserDomains: []string{"www.aa.com"},
FrontendPort: "80",
BackendPort: "8080",
Proto: "HTTP",
Enabled: true,
},
},
}
ret := `{
"containerIps": [
Expand Down Expand Up @@ -350,7 +362,17 @@ func TestServicesInspect(t *testing.T) {
"name": "v2",
"unitType": "SSD1_16G"
}
]
],
"apPorts": [{
"apId": "1000001",
"type": "DOMAIN",
"domain": "abcd1234",
"userDomains": ["www.aa.com"],
"frontendPort": "80",
"backendPort": "8080",
"proto": "HTTP",
"enabled": true
}]
}`
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, expectedUrl, r.URL.Path)
Expand Down

0 comments on commit 53cc577

Please sign in to comment.