-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from nowenL/master
SDK Source code initial checkin
- Loading branch information
Showing
22 changed files
with
3,840 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
language: go | ||
|
||
go: | ||
- 1.7 | ||
|
||
env: | ||
- PROJECT_ROOT=$HOME/gopath/src/qiniupkg.com | ||
|
||
before_install: | ||
- mkdir -p $PROJECT_ROOT | ||
- cp -vr $TRAVIS_BUILD_DIR $PROJECT_ROOT | ||
- cd $PROJECT_ROOT | ||
|
||
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 | ||
|
||
script: | ||
- make style | ||
- make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Release 0.1.0 | ||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 安装 | ||
- 安装 [go 1.7](https://golang.org/dl/) 以上版本 | ||
- 安装 [glide](https://glide.sh) 包管理工具 | ||
|
||
# 开发环境配置 | ||
同步项目代码: | ||
```bash | ||
$ git clone https://github.com/qiniu/kirk.git | ||
``` | ||
|
||
本项目采用 glide 管理包依赖,你可以使用如下命令下载开发中需要用到的包,这些包会被下载到vendor目录下: | ||
```bash | ||
$ glide install | ||
``` | ||
|
||
如果改动中引入了新的依赖,请使用如下命令更新 glide 配置文件 [glide.yaml](glide.yaml) 和 [glide.lock](glide.yaml) 并将其包含在PR中 | ||
```bash | ||
$ glide up | ||
$ glide install | ||
``` | ||
|
||
# 提交PR | ||
- 在着手影响较大的代码改动,尤其是 breaking change 前,请先建立issue,与本项目组充分沟通并确定修改方案后再开工 | ||
- 提交PR前,请确保代码格式检查以及单元测试通过 | ||
```bash | ||
$ make style | ||
$ make test | ||
``` | ||
- 如果改动涉及 SDK 的公开接口,请更新代码中相应的注释 | ||
- 尽量保证每个commit包含一个独立的改动,并在 [CHANGELOG.md](CHANGELOG.md) 添加改动内容 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SOURCEDIR = kirksdk | ||
GLIDENOVENDOR = $(shell glide novendor) | ||
|
||
test: | ||
go test $(GLIDENOVENDOR) | ||
|
||
fmt: | ||
gofmt -w $(SOURCEDIR) | ||
|
||
style: | ||
gofmt -l $(SOURCEDIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,100 @@ | ||
[![Qiniu Logo](http://open.qiniudn.com/logo.png)](http://qiniu.com/) | ||
|
||
QINIU KIRK | ||
=============== | ||
# QINIU KIRK | ||
[![GoDoc](https://godoc.org/qiniupkg.com/kirk?status.svg)](https://godoc.org/qiniupkg.com/kirk) | ||
|
||
文档 | ||
=============== | ||
# 简介 | ||
本 SDK 基于 golang 语言, 用于与 QINIU KIRK 通用计算平台 REST API 的编程交互,提供了在开发者业务服务器(服务端或客户端)管理七牛容器云资源的能力。 | ||
|
||
# 安装 | ||
> 本 SDK 需要 [go 1.7](https://golang.org/dl/) 以上版本 | ||
## 使用 go get 安装 | ||
``` | ||
$ go get -u qiniupkg.com/kirk/kirksdk | ||
``` | ||
|
||
## 使用 [glide](https://glide.sh) 安装 | ||
- 安装 [glide](https://glide.sh) 包管理工具 | ||
- 在项目有中添加一个 import “qiniupkg.com/kirk/kirksdk” 的 .go 源文件,并执行如下命令。glide会自动扫描代码并下载需要的包 | ||
``` | ||
$ cd your_project_dir | ||
$ glide init | ||
$ glide install | ||
``` | ||
# 示例 | ||
## 创建 App | ||
```golang | ||
import "qiniupkg.com/kirk/kirksdk" | ||
|
||
... | ||
|
||
cfg := kirksdk.AccountConfig{ | ||
AccessKey: ACCESS_KEY, | ||
SecretKey: SECRET_KEY, | ||
Host: kirksdk.DefaultAccountHost, | ||
} | ||
|
||
accountClient := kirksdk.NewAccountClient(cfg) | ||
|
||
createdApp, err := accountClient.CreateApp(context.TODO(), "myapp", kirksdk.CreateAppArgs{ | ||
Title: "title", | ||
Region: "nq", | ||
}) | ||
|
||
if err != nil { | ||
// 错误处理 | ||
} | ||
|
||
fmt.Println(createdApp.URI) | ||
``` | ||
|
||
## 在 App 下创建 Service | ||
```golang | ||
import "qiniupkg.com/kirk/kirksdk" | ||
|
||
... | ||
|
||
qcosClient, err := accountClient.GetQcosClient(context.TODO(), createdApp.URI) | ||
if err != nil { | ||
// 错误处理 | ||
} | ||
|
||
err = qcosClient.CreateService(context.TODO(), "mystack", kirksdk.CreateServiceArgs{ | ||
Name: "myservice", | ||
}) | ||
if err != nil { | ||
// 错误处理 | ||
} | ||
``` | ||
|
||
## 列出账号下所有镜像仓库 | ||
```golang | ||
import "qiniupkg.com/kirk/kirksdk" | ||
|
||
... | ||
|
||
accountInfo, err := accountClient.GetAccountInfo(context.TODO()) | ||
if err != nil { | ||
// 错误处理 | ||
} | ||
|
||
indexClient, err := accountClient.GetIndexClient(context.TODO()) | ||
if err != nil { | ||
// 错误处理 | ||
} | ||
|
||
repos, err := indexClient.ListRepo(context.TODO(), accountInfo.Name) | ||
if err != nil { | ||
// 错误处理 | ||
} | ||
|
||
for _, repo := range repos { | ||
fmt.Println(repo.Name) | ||
} | ||
``` | ||
|
||
# 相关文档 | ||
- [qiniupkg.com/kirk](https://godoc.org/qiniupkg.com/kirk) | ||
- [开放API和SDK文档](http://kirk-docs.qiniu.com/apidocs/?go) | ||
- [产品文档](http://kirk-docs.qiniu.com/) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package: qiniupkg.com/kirk | ||
homepage: https://qiniu.com | ||
license: MIT | ||
import: | ||
- package: github.com/Sirupsen/logrus | ||
version: ~0.10.0 | ||
- package: golang.org/x/net | ||
subpackages: | ||
- context | ||
- package: qiniupkg.com/api.v7 | ||
version: ^7.0.5 | ||
subpackages: | ||
- conf | ||
- package: qiniupkg.com/x | ||
version: ^7.0.8 | ||
subpackages: | ||
- bytes.v7/seekable | ||
- rpc.v7 | ||
testImport: | ||
- package: github.com/stretchr/testify | ||
version: ^1.1.4 | ||
subpackages: | ||
- assert |
Oops, something went wrong.