From 1194691946fd5df613583983f5614742cc1a5f7a Mon Sep 17 00:00:00 2001 From: wzj Date: Wed, 28 Dec 2016 13:20:47 +0800 Subject: [PATCH 1/8] fix vendorManagedAppStatus responce --- CHANGELOG.md | 1 + kirksdk/account_api.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 062ff03..fe2ebc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # vNext +- vendorManaged 应用状态的responce 改details为message # 2.1.0 - 新增应用平台user权限的接口 diff --git a/kirksdk/account_api.go b/kirksdk/account_api.go index 9a53493..2fc889c 100644 --- a/kirksdk/account_api.go +++ b/kirksdk/account_api.go @@ -243,7 +243,7 @@ type SpecInfo struct { // VendorManagedAppStatus 包含应用运行状态信息 type VendorManagedAppStatus struct { Status string `json:"status"` - Details string `json:"details"` + Message string `json:"details"` } // VendorManagedAppEntry 包含应用入口地址 From 40c51eb5191c0dcfa492247ab910e21de7673726 Mon Sep 17 00:00:00 2001 From: wzj Date: Wed, 28 Dec 2016 14:57:27 +0800 Subject: [PATCH 2/8] fix --- kirksdk/account_api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kirksdk/account_api.go b/kirksdk/account_api.go index 2fc889c..3cefe4c 100644 --- a/kirksdk/account_api.go +++ b/kirksdk/account_api.go @@ -243,7 +243,7 @@ type SpecInfo struct { // VendorManagedAppStatus 包含应用运行状态信息 type VendorManagedAppStatus struct { Status string `json:"status"` - Message string `json:"details"` + Message string `json:"message"` } // VendorManagedAppEntry 包含应用入口地址 From daa5fa9be457bae1e67c0ceb227712f6bbee1191 Mon Sep 17 00:00:00 2001 From: wzj Date: Wed, 28 Dec 2016 16:59:20 +0800 Subject: [PATCH 3/8] fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2ebc5..9749c8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # vNext -- vendorManaged 应用状态的responce 改details为message +- vendorManaged 应用状态的response 改details为message # 2.1.0 - 新增应用平台user权限的接口 From 4319a07815498f7328b9b143154e302500858c14 Mon Sep 17 00:00:00 2001 From: leiiwang Date: Tue, 20 Dec 2016 18:20:07 +0800 Subject: [PATCH 4/8] QCOS-3511 support get image size in api --- CHANGELOG.md | 1 + kirksdk/index_api.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e06d86..84d09f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # vNext - 为 Service 以及 Job 增加 Confs 域 - 增加 ConfigService 相关 V3 接口 +- ListRepoTags和GetImageConfig 支持获取imagesize # Release 1.1.0 - AccountClient 相关 API 使用 appd V3 接口 diff --git a/kirksdk/index_api.go b/kirksdk/index_api.go index 4ea12e2..18209db 100644 --- a/kirksdk/index_api.go +++ b/kirksdk/index_api.go @@ -36,8 +36,9 @@ type Repo struct { } type Tag struct { - Name string `json:"name"` - Created time.Time `json:"created"` + Name string `json:"name"` + Created time.Time `json:"created"` + Detail ImageConfig `json:"detail"` } type ImageConfig struct { @@ -47,6 +48,7 @@ type ImageConfig struct { Config map[string]interface{} `json:"config"` ContainerConfig map[string]interface{} `json:"container_config"` Created time.Time `json:"created"` + Size int64 `json:"size"` } type Digest string From 33337f9caf8cca81ccf753b7b8a45955de528056 Mon Sep 17 00:00:00 2001 From: leiiwang Date: Thu, 5 Jan 2017 13:53:27 +0800 Subject: [PATCH 5/8] QCOS-0 update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 711f7c9..e856e00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # vNext - vendorManaged 应用状态的response 改details为message +- ListRepoTags和GetImageConfig 支持获取imagesize # 2.1.0 - 新增应用平台user权限的接口 @@ -16,7 +17,6 @@ - 查看服务时,给出与该服务关联的AP端口信息。 - 为 Service 以及 Job 增加 Confs 域 - 增加 ConfigService 相关 V3 接口 -- ListRepoTags和GetImageConfig 支持获取imagesize - 为 index 列取tag 接口增加排序,分页和时间参数 # Release 1.1.0 From 162bfbc7b7762f8635db841915dcd65eb5064209 Mon Sep 17 00:00:00 2001 From: wzj Date: Thu, 5 Jan 2017 15:03:35 +0800 Subject: [PATCH 6/8] add Privileges for spec and app --- CHANGELOG.md | 1 + kirksdk/account_api.go | 35 +++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e856e00..12d5f0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # vNext - vendorManaged 应用状态的response 改details为message - ListRepoTags和GetImageConfig 支持获取imagesize +- spec和app添加Privileges字段 # 2.1.0 - 新增应用平台user权限的接口 diff --git a/kirksdk/account_api.go b/kirksdk/account_api.go index 3cefe4c..6b00df4 100644 --- a/kirksdk/account_api.go +++ b/kirksdk/account_api.go @@ -127,10 +127,11 @@ type AccountConfig struct { // CreateAppArgs 包含创建一个 App 所需的信息 type CreateAppArgs struct { - Title string `json:"title"` - Region string `json:"region"` - SpecURI string `json:"specUri"` - SpecVer uint32 `json:"specVer"` + Title string `json:"title"` + Region string `json:"region"` + SpecURI string `json:"specUri"` + SpecVer uint32 `json:"specVer"` + Privileges []string `json:"privileges"` } // AccountInfo 包含 Account 的相关信息 @@ -153,6 +154,7 @@ type AppInfo struct { RunMode string `json:"runMode,omitempty"` CreationTime time.Time `json:"ctime"` ModificationTime time.Time `json:"mtime"` + Privileges []string `json:"privileges,omitempty"` AppExtendedInfo } @@ -226,18 +228,19 @@ type GrantedAppKey struct { // SpecInfo 包含 Spec 的相关信息 type SpecInfo struct { - URI string `json:"uri"` - Owner string `json:"owner"` - Title string `json:"title"` - Ver uint32 `json:"ver"` - Verstr string `json:"verstr"` - Desc string `json:"desc,omitempty"` - Brief string `json:"brief"` - Icon string `json:"icon"` - Seedimg string `json:"seedimg"` - Entryport uint16 `json:"entryport"` - Ctime time.Time `json:"ctime"` - Mtime time.Time `json:"mtime"` + URI string `json:"uri"` + Owner string `json:"owner"` + Title string `json:"title"` + Ver uint32 `json:"ver"` + Verstr string `json:"verstr"` + Desc string `json:"desc,omitempty"` + Brief string `json:"brief"` + Icon string `json:"icon"` + Seedimg string `json:"seedimg"` + Entryport uint16 `json:"entryport"` + Privileges []string `json:"privileges"` + Ctime time.Time `json:"ctime"` + Mtime time.Time `json:"mtime"` } // VendorManagedAppStatus 包含应用运行状态信息 From 1936cf35f07c4b59bd41979399c78cf03b6591b6 Mon Sep 17 00:00:00 2001 From: "longwenlu@gmail.com" Date: Mon, 9 Jan 2017 17:28:21 +0800 Subject: [PATCH 7/8] QCOS-3526 Add GetConfig function for all clients --- CHANGELOG.md | 1 + kirksdk/account_api.go | 2 ++ kirksdk/account_client.go | 8 +++++++- kirksdk/account_client_test.go | 20 ++++++++++++++++++++ kirksdk/index_api.go | 2 ++ kirksdk/index_auth_client.go | 7 ++++++- kirksdk/index_auth_client_test.go | 20 ++++++++++++++++++++ kirksdk/index_client.go | 6 ++++++ kirksdk/index_client_test.go | 22 ++++++++++++++++++++++ kirksdk/qcos_api.go | 2 ++ kirksdk/qcos_client.go | 6 ++++++ kirksdk/qcos_client_test.go | 13 +++++++++++++ 12 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 kirksdk/account_client_test.go create mode 100644 kirksdk/index_auth_client_test.go create mode 100644 kirksdk/index_client_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 12d5f0b..2257297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - vendorManaged 应用状态的response 改details为message - ListRepoTags和GetImageConfig 支持获取imagesize - spec和app添加Privileges字段 +- 为各个 Client 接口添加 GetConfig 方法 # 2.1.0 - 新增应用平台user权限的接口 diff --git a/kirksdk/account_api.go b/kirksdk/account_api.go index 6b00df4..c37eae3 100644 --- a/kirksdk/account_api.go +++ b/kirksdk/account_api.go @@ -32,6 +32,8 @@ const ( // AccountClient 包含针对账号 REST API 的各项操作 type AccountClient interface { + // GetConfig 返回用于创建本 Client 实例的 AccountConfig + GetConfig() (ret AccountConfig) // GetAccountInfo 用于得到 Account 的相关信息 GetAccountInfo(ctx context.Context) (ret AccountInfo, err error) diff --git a/kirksdk/account_client.go b/kirksdk/account_client.go index ccc77fe..0c180cc 100644 --- a/kirksdk/account_client.go +++ b/kirksdk/account_client.go @@ -16,6 +16,7 @@ const appVersionPrefix = "/v3" var ErrInvalidAppURI = errors.New("app uri is invalid") type accountClientImp struct { + config AccountConfig accessKey string secretKey string host string @@ -27,6 +28,7 @@ type accountClientImp struct { func NewAccountClient(cfg AccountConfig) AccountClient { p := new(accountClientImp) + p.config = cfg p.host = cleanHost(cfg.Host) p.transport = cfg.Transport p.userAgent = cfg.UserAgent @@ -44,6 +46,10 @@ func NewAccountClient(cfg AccountConfig) AccountClient { return p } +func (p *accountClientImp) GetConfig() (ret AccountConfig) { + return p.config +} + func (p *accountClientImp) GetAccountInfo(ctx context.Context) (ret AccountInfo, err error) { url := fmt.Sprintf("%s%s/info", p.host, appVersionPrefix) err = p.client.Call(ctx, &ret, "GET", url) @@ -289,7 +295,7 @@ func (p *accountClientImp) GetQcosClient(ctx context.Context, appURI string) (cl go func() { result := getKeyFunc() - if result.ak == "" { + if result.ak == "" && result.err == nil { result.err = fmt.Errorf("Fail to find keys for app \"%s\"", appURI) } diff --git a/kirksdk/account_client_test.go b/kirksdk/account_client_test.go new file mode 100644 index 0000000..29e32bc --- /dev/null +++ b/kirksdk/account_client_test.go @@ -0,0 +1,20 @@ +package kirksdk + +import ( + "github.com/stretchr/testify/assert" + "net/http" + "testing" +) + +func TestAccountGetConfig(t *testing.T) { + config := AccountConfig{ + AccessKey: "ak", + SecretKey: "sk", + Host: "https://account.test.url", + UserAgent: "account.ua", + Transport: http.DefaultTransport, + } + + client := NewAccountClient(config) + assert.EqualValues(t, config, client.GetConfig()) +} diff --git a/kirksdk/index_api.go b/kirksdk/index_api.go index 22eefc3..d03ea17 100644 --- a/kirksdk/index_api.go +++ b/kirksdk/index_api.go @@ -8,10 +8,12 @@ import ( ) type IndexAuthClient interface { + GetConfig() (ret IndexAuthConfig) RequestAuthToken(ctx context.Context, scopes []string) (AuthToken, error) } type IndexClient interface { + GetConfig() (ret IndexConfig) 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) diff --git a/kirksdk/index_auth_client.go b/kirksdk/index_auth_client.go index 3966e2c..7ed35ee 100644 --- a/kirksdk/index_auth_client.go +++ b/kirksdk/index_auth_client.go @@ -19,6 +19,7 @@ type IndexAuthConfig struct { } type indexAuthClientImp struct { + config IndexAuthConfig Host string client rpc.Client } @@ -26,7 +27,7 @@ type indexAuthClientImp struct { func NewIndexAuthClient(cfg IndexAuthConfig) IndexAuthClient { p := new(indexAuthClientImp) - + p.config = cfg p.Host = cleanHost(cfg.Host) cfg.Transport = newKirksdkTransport(cfg.UserAgent, cfg.Transport) @@ -41,6 +42,10 @@ func NewIndexAuthClient(cfg IndexAuthConfig) IndexAuthClient { return p } +func (p *indexAuthClientImp) GetConfig() (ret IndexAuthConfig) { + return p.config +} + func (p *indexAuthClientImp) RequestAuthToken(ctx context.Context, scopes []string) (AuthToken, error) { param := url.Values{"scope": scopes} token := new(AuthToken) diff --git a/kirksdk/index_auth_client_test.go b/kirksdk/index_auth_client_test.go new file mode 100644 index 0000000..b9b8825 --- /dev/null +++ b/kirksdk/index_auth_client_test.go @@ -0,0 +1,20 @@ +package kirksdk + +import ( + "github.com/stretchr/testify/assert" + "net/http" + "testing" +) + +func TestIndexAuthGetConfig(t *testing.T) { + config := IndexAuthConfig{ + AccessKey: "ak", + SecretKey: "sk", + Host: "https://index.auth.test.url", + UserAgent: "index.ua", + Transport: http.DefaultTransport, + } + + client := NewIndexAuthClient(config) + assert.EqualValues(t, config, client.GetConfig()) +} diff --git a/kirksdk/index_client.go b/kirksdk/index_client.go index 6203fa6..e486e00 100644 --- a/kirksdk/index_client.go +++ b/kirksdk/index_client.go @@ -20,6 +20,7 @@ type IndexConfig struct { } type indexClientImp struct { + config IndexConfig host string client rpc.Client } @@ -27,6 +28,7 @@ type indexClientImp struct { func NewIndexClient(cfg IndexConfig) IndexClient { p := new(indexClientImp) + p.config = cfg cfg.Host = cleanHost(cfg.Host) p.host = cfg.Host @@ -37,6 +39,10 @@ func NewIndexClient(cfg IndexConfig) IndexClient { return p } +func (p *indexClientImp) GetConfig() (ret IndexConfig) { + return p.config +} + func (p *indexClientImp) ListRepo(ctx context.Context, username string) (repos []*Repo, err error) { err = p.client.Call(ctx, &repos, "GET", fmt.Sprintf("%s/api/%s/repos", p.host, username)) return diff --git a/kirksdk/index_client_test.go b/kirksdk/index_client_test.go new file mode 100644 index 0000000..8d0dae8 --- /dev/null +++ b/kirksdk/index_client_test.go @@ -0,0 +1,22 @@ +package kirksdk + +import ( + "github.com/stretchr/testify/assert" + "net/http" + "testing" +) + +func TestIndexGetConfig(t *testing.T) { + config := IndexConfig{ + AccessKey: "ak", + SecretKey: "sk", + Host: "https://index.test.url", + RootApp: "root", + AuthHost: "https://index.auth.test.url", + UserAgent: "index.ua", + Transport: http.DefaultTransport, + } + + client := NewIndexClient(config) + assert.EqualValues(t, config, client.GetConfig()) +} diff --git a/kirksdk/qcos_api.go b/kirksdk/qcos_api.go index cc75a7a..dce37ed 100644 --- a/kirksdk/qcos_api.go +++ b/kirksdk/qcos_api.go @@ -9,6 +9,8 @@ import ( ) type QcosClient interface { + GetConfig() (ret QcosConfig) + // GET /v3/stacks ListStacks(ctx context.Context) (ret []StackInfo, err error) diff --git a/kirksdk/qcos_client.go b/kirksdk/qcos_client.go index cb0e498..ce46e39 100644 --- a/kirksdk/qcos_client.go +++ b/kirksdk/qcos_client.go @@ -37,6 +37,7 @@ type QcosConfig struct { } type qcosClientImp struct { + config QcosConfig host string logger *logrus.Logger client rpc.Client @@ -46,6 +47,7 @@ type qcosClientImp struct { func NewQcosClient(cfg QcosConfig) QcosClient { p := new(qcosClientImp) + p.config = cfg p.host = cleanHost(cfg.Host) @@ -66,6 +68,10 @@ func NewQcosClient(cfg QcosConfig) QcosClient { return p } +func (p *qcosClientImp) GetConfig() (ret QcosConfig) { + return p.config +} + // GET /v3/stacks func (p *qcosClientImp) ListStacks(ctx context.Context) (ret []StackInfo, err error) { diff --git a/kirksdk/qcos_client_test.go b/kirksdk/qcos_client_test.go index 6781389..bb49a09 100644 --- a/kirksdk/qcos_client_test.go +++ b/kirksdk/qcos_client_test.go @@ -13,6 +13,19 @@ import ( "github.com/stretchr/testify/assert" ) +func TestQcosGetConfig(t *testing.T) { + config := QcosConfig{ + AccessKey: "ak", + SecretKey: "sk", + Host: "https://test.url", + UserAgent: "ua", + Transport: http.DefaultTransport, + } + + client := NewQcosClient(config) + assert.EqualValues(t, config, client.GetConfig()) +} + func TestStacks(t *testing.T) { expectedUrl := "/v3/stacks" expectedMethod := "GET" From ab8a4bd2760ab7a6637e43e22bbf518f2e7fcbc5 Mon Sep 17 00:00:00 2001 From: "longwenlu@gmail.com" Date: Tue, 10 Jan 2017 16:40:57 +0800 Subject: [PATCH 8/8] QCOS-0 Prepare for release 2.2.0 --- .travis.yml | 3 ++- CHANGELOG.md | 4 +++- kirksdk/kirksdk.go | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 646d949..72c62d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,8 @@ install: - go get -v github.com/Masterminds/glide - cd $GOPATH/src/github.com/Masterminds/glide && git checkout 84607742b10f492430762d038e954236bbaf23f7 && go install - cd $PROJECT_ROOT/kirk - - glide install + - echo $GOPATH + - glide --debug install script: - make style diff --git a/CHANGELOG.md b/CHANGELOG.md index 2257297..ba62fd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ # vNext + +# Release 2.2.0 - vendorManaged 应用状态的response 改details为message - ListRepoTags和GetImageConfig 支持获取imagesize - spec和app添加Privileges字段 - 为各个 Client 接口添加 GetConfig 方法 -# 2.1.0 +# Release 2.1.0 - 新增应用平台user权限的接口 - 修改日志搜索返回结果字段及其Tag diff --git a/kirksdk/kirksdk.go b/kirksdk/kirksdk.go index 314fa8a..2c94e78 100644 --- a/kirksdk/kirksdk.go +++ b/kirksdk/kirksdk.go @@ -1,3 +1,3 @@ package kirksdk -const Version = "2.1.0" +const Version = "2.2.0"