Skip to content

Commit

Permalink
Merge branch 'release/v0.9.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
moooofly committed Sep 29, 2018
2 parents eaa6c2b + 56a31a5 commit 5dd4268
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 45 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<a name="0.9.5"></a>
# [0.9.5](https://github.com/moooofly/harbor-go-client/compare/v0.9.4...v0.9.5) (2018-09-29)

* do some trivial ajustments


<a name="0.9.4"></a>
# [0.9.4](https://github.com/moooofly/harbor-go-client/compare/v0.9.3...v0.9.4) (2018-09-16)

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ Current Harbor API support status:
- [x] GET /api/jobs/replication/{id}/log
- [x] GET /api/jobs/scan/{id}/log
- policies
- [ ] GET /api/policies/replication
- [ ] POST /api/policies/replication
- [ ] GET /api/policies/replication/{id}
- [ ] PUT /api/policies/replication/{id}
- [x] GET /api/policies/replication
- [x] POST /api/policies/replication
- [x] GET /api/policies/replication/{id}
- [x] PUT /api/policies/replication/{id}
- labels
- [ ] GET /api/labels
- [ ] POST /api/labels
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.9.4
v0.9.5
1 change: 1 addition & 0 deletions api/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func DeletePrjMemberDel(baseURL string) {
*/

// ProjectMember defines the member settings of a project.
type ProjectMember struct {
RoleID int `json:"role_id,omitempty"`
MemberUser struct {
Expand Down
15 changes: 7 additions & 8 deletions api/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func init() {
&repoImageScan)
utils.Parser.AddCommand("repo_image_manifests_get",
"Get manifests of a relevant repository.",
"This endpoint aims to retreive manifests from a relevant repository.",
"This endpoint aims to retrieve manifests from a relevant repository.",
&repoImageManifestsGet)
utils.Parser.AddCommand("repo_image_label_del",
"Delete label from the image under specific repository.",
Expand Down Expand Up @@ -118,7 +118,7 @@ func (x *repositoryImageManifestsGet) Execute(args []string) error {
return nil
}

// GetRepoImageManifest aims to retreive manifests from a relevant repository.
// GetRepoImageManifest aims to retrieve manifests from a relevant repository.
//
// params:
// repo_name - (REQUIRED) The name of repository.
Expand Down Expand Up @@ -184,7 +184,7 @@ type repositoryImageLabelAdd struct {
Name string `long:"name" description:"The name of this label." default:"" json:"name"`
Description string `long:"description" description:"The description of this label." default:"" json:"description"`
Color string `long:"color" description:"The color code of this label. (e.g. Format: #A9B6BE)" default:"" json:"color"`
Scope string `long:"scope" description:"The scope of this label. ('p' indicats project scope, 'g' indicates global scope)" default:"" json:"scope"`
Scope string `long:"scope" description:"The scope of this label. ('p' indicates project scope, 'g' indicates global scope)" default:"" json:"scope"`
ProjectID int `long:"project_id" description:"Which project (id) this label belongs to when created. ('0' indicates global label, others indicate specific project)" default:"" json:"project_id"`
CreationTime string `long:"creation_time" description:"The creation time of this label. default time.Now()" default:"" json:"creation_time"`
UpdateTime string `long:"update_time" description:"The update time of this label. default time.Now()" default:"" json:"update_time"`
Expand All @@ -207,7 +207,7 @@ func (x *repositoryImageLabelAdd) Execute(args []string) error {
// name - The name of this label.
// description - The description of this label.
// color - The color code of this label. (e.g. Format: #A9B6BE)
// scope - The scope of this label. ('p' indicats project scope, 'g' indicates global scope)
// scope - The scope of this label. ('p' indicates project scope, 'g' indicates global scope)
// project_id - Which project (id) this label belongs to when created. ('0' indicates global label, others indicate specific project)
// creation_time - The creation time of this label. default time.Now()
// update_time - The update time of this label. default time.Now()
Expand Down Expand Up @@ -300,7 +300,7 @@ func (x *repositoryLabelDel) Execute(args []string) error {
return nil
}

// DelRepoByRepoName deletes the label from the repository specified by the repo_name.
// DeleteRepoLabel deletes the label from the repository specified by the repo_name.
//
// params:
// repo_name - (REQUIRED) The name of repository that you want to delete a label from.
Expand Down Expand Up @@ -330,7 +330,7 @@ type repositoryLabelAdd struct {
Name string `long:"name" description:"The name of this label." default:"" json:"name"`
Description string `long:"description" description:"The description of this label." default:"" json:"description"`
Color string `long:"color" description:"The color code of this label. (e.g. Format: #A9B6BE)" default:"" json:"color"`
Scope string `long:"scope" description:"The scope of this label. ('p' indicats project scope, 'g' indicates global scope)" default:"" json:"scope"`
Scope string `long:"scope" description:"The scope of this label. ('p' indicates project scope, 'g' indicates global scope)" default:"" json:"scope"`
ProjectID int `long:"project_id" description:"Which project (id) this label belongs to when created. ('0' indicates global label, others indicate specific project)" default:"" json:"project_id"`
CreationTime string `long:"creation_time" description:"The creation time of this label. default time.Now()" default:"" json:"creation_time"`
UpdateTime string `long:"update_time" description:"The update time of this label. default time.Now()" default:"" json:"update_time"`
Expand All @@ -352,7 +352,7 @@ func (x *repositoryLabelAdd) Execute(args []string) error {
// name - The name of this label.
// description - The description of this label.
// color - The color code of this label. (e.g. Format: #A9B6BE)
// scope - The scope of this label. ('p' indicats project scope, 'g' indicates global scope)
// scope - The scope of this label. ('p' indicates project scope, 'g' indicates global scope)
// project_id - Which project (id) this label belongs to when created. ('0' indicates global label, others indicate specific project)
// creation_time - The creation time of this label. default time.Now()
// update_time - The update time of this label. default time.Now()
Expand Down Expand Up @@ -456,7 +456,6 @@ curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/pla
"description": "change" \
}' 'https://localhost/api/repositories/temp_5%2Fhello-world'
*/

func PutRepoDescriptionUpdate(baseURL string) {
targetURL := baseURL + "/" + repoUpdate.RepoName
fmt.Println("==> PUT", targetURL)
Expand Down
64 changes: 32 additions & 32 deletions api/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,46 @@ func init() {
utils.Parser.AddCommand("user_update_role",
"Update a registered user to change to be an administrator of Harbor.",
"This endpoint let a registered user change to be an administrator of Harbor.",
&user_update_role)
&usrUpdateRole)
utils.Parser.AddCommand("user_update_password",
"Change the password on a user that already exists.",
"This endpoint is for user to update password. Users with the admin role can change any user's password. Guest users can change only their own password.",
&user_update_password)
&usrUpdatePassword)
utils.Parser.AddCommand("user_update",
"Update a registered user to change his profile.",
"This endpoint let a registered user change his profile.",
&user_update)
&usrUpdate)
utils.Parser.AddCommand("user_get",
"Get a user's profile.",
"Get user's profile with user id.",
&user_get)
&usrGet)
utils.Parser.AddCommand("user_delete",
"Mark a registered user as be removed.",
"This endpoint let administrator of Harbor mark a registered user as be removed. It actually won't be deleted from DB.",
&user_delete)
&usrDelete)
utils.Parser.AddCommand("user_create",
"Creates a new user account.",
"This endpoint is to create a user if the user does not already exist.",
&user_create)
&usrCreate)
utils.Parser.AddCommand("users_search",
"Get registered users of Harbor.",
"This endpoint is for user to search registered users, support for filtering results with username. Notice, by now this operation is only for administrator.",
&users_search)
&usrSearch)
// NOTE:
// 由于 user_current 命令是是用于列出当前 login 用户相关信息
// 故将其改名为 whoami
utils.Parser.AddCommand("whoami",
"Show info about current login user only.",
"Maybe 'whoami' is a better name.",
&user_current)
&usrCurrent)
}

type userUpdateRole struct {
UserID int `short:"i" long:"user_id" description:"(REQUIRED) Registered user ID." required:"yes" json:"-"`
HasAdminRole int `short:"r" long:"has_admin_role" description:"(REQUIRED) Toggle a user to admin or not." required:"yes" json:"has_admin_role"`
}

var user_update_role userUpdateRole
var usrUpdateRole userUpdateRole

func (x *userUpdateRole) Execute(args []string) error {
PutUserUpdateRole(utils.URLGen("/api/users"))
Expand All @@ -74,7 +74,7 @@ func (x *userUpdateRole) Execute(args []string) error {
// }' 'https://localhost/api/users/1/sysadmin'
//
func PutUserUpdateRole(baseURL string) {
targetURL := baseURL + "/" + strconv.Itoa(user_update_role.UserID) + "/sysadmin"
targetURL := baseURL + "/" + strconv.Itoa(usrUpdateRole.UserID) + "/sysadmin"

fmt.Println("==> PUT", targetURL)

Expand All @@ -85,7 +85,7 @@ func PutUserUpdateRole(baseURL string) {
return
}

t, err := json.Marshal(&user_update_role)
t, err := json.Marshal(&usrUpdateRole)
if err != nil {
fmt.Println("error:", err)
return
Expand All @@ -105,7 +105,7 @@ type userUpdatePassword struct {
NewPassword string `short:"n" long:"new_password" description:"(REQUIRED) New password." required:"yes" json:"new_password"`
}

var user_update_password userUpdatePassword
var usrUpdatePassword userUpdatePassword

func (x *userUpdatePassword) Execute(args []string) error {
PutUserUpdatePassword(utils.URLGen("/api/users"))
Expand All @@ -129,7 +129,7 @@ func (x *userUpdatePassword) Execute(args []string) error {
// }' 'https://localhost/api/users/1/password'
//
func PutUserUpdatePassword(baseURL string) {
targetURL := baseURL + "/" + strconv.Itoa(user_update_password.UserID) + "/password"
targetURL := baseURL + "/" + strconv.Itoa(usrUpdatePassword.UserID) + "/password"

fmt.Println("==> PUT", targetURL)

Expand All @@ -140,7 +140,7 @@ func PutUserUpdatePassword(baseURL string) {
return
}

t, err := json.Marshal(&user_update_password)
t, err := json.Marshal(&usrUpdatePassword)
if err != nil {
fmt.Println("error:", err)
return
Expand All @@ -162,7 +162,7 @@ type userUpdate struct {
Comment string `short:"m" long:"comment" description:"(REQUIRED) Custom comment." required:"yes" json:"comment"`
}

var user_update userUpdate
var usrUpdate userUpdate

func (x *userUpdate) Execute(args []string) error {
PutUserUpdate(utils.URLGen("/api/users"))
Expand All @@ -188,7 +188,7 @@ func (x *userUpdate) Execute(args []string) error {
// }' 'https://localhost/api/users/1'
//
func PutUserUpdate(baseURL string) {
targetURL := baseURL + "/" + strconv.Itoa(user_update.UserID)
targetURL := baseURL + "/" + strconv.Itoa(usrUpdate.UserID)

fmt.Println("==> PUT", targetURL)

Expand All @@ -199,7 +199,7 @@ func PutUserUpdate(baseURL string) {
return
}

t, err := json.Marshal(&user_update)
t, err := json.Marshal(&usrUpdate)
if err != nil {
fmt.Println("error:", err)
return
Expand All @@ -217,7 +217,7 @@ type userGet struct {
UserID int `short:"i" long:"user_id" description:"(REQUIRED) Registered user ID." required:"yes"`
}

var user_get userGet
var usrGet userGet

func (x *userGet) Execute(args []string) error {
GetUserProfile(utils.URLGen("/api/users"))
Expand All @@ -235,7 +235,7 @@ func (x *userGet) Execute(args []string) error {
// e.g. curl -X GET --header 'Accept: text/plain' 'https://localhost/api/users/1'
//
func GetUserProfile(baseURL string) {
targetURL := baseURL + "/" + strconv.Itoa(user_get.UserID)
targetURL := baseURL + "/" + strconv.Itoa(usrGet.UserID)

fmt.Println("==> GET", targetURL)

Expand All @@ -255,7 +255,7 @@ type userDelete struct {
UserID int `short:"i" long:"user_id" description:"(REQUIRED) User ID for marking as to be removed." required:"yes"`
}

var user_delete userDelete
var usrDelete userDelete

func (x *userDelete) Execute(args []string) error {
DeleteUser(utils.URLGen("/api/users"))
Expand All @@ -273,7 +273,7 @@ func (x *userDelete) Execute(args []string) error {
// e.g. curl -X DELETE --header 'Accept: text/plain' 'https://localhost/api/users/1'
//
func DeleteUser(baseURL string) {
targetURL := baseURL + "/" + strconv.Itoa(user_delete.UserID)
targetURL := baseURL + "/" + strconv.Itoa(usrDelete.UserID)

fmt.Println("==> DELETE", targetURL)

Expand Down Expand Up @@ -307,7 +307,7 @@ type userCreate struct {
UpdateTime string `short:"u" long:"update_time" description:"User's update time. Default time.Now()." default:"" json:"update_time"`
}

var user_create userCreate
var usrCreate userCreate

func (x *userCreate) Execute(args []string) error {
PostUserCreate(utils.URLGen("/api/users"))
Expand Down Expand Up @@ -354,10 +354,10 @@ func (x *userCreate) Execute(args []string) error {
// }' 'https://localhost/api/users'
//
func PostUserCreate(baseURL string) {
if user_create.CreationTime == "" || user_create.UpdateTime == "" {
if usrCreate.CreationTime == "" || usrCreate.UpdateTime == "" {
now := time.Now().Format("2006-01-02T15:04:05Z")
user_create.CreationTime = now
user_create.UpdateTime = now
usrCreate.CreationTime = now
usrCreate.UpdateTime = now
}

targetURL := baseURL
Expand All @@ -370,7 +370,7 @@ func PostUserCreate(baseURL string) {
return
}

t, err := json.Marshal(&user_create)
t, err := json.Marshal(&usrCreate)
if err != nil {
fmt.Println("error:", err)
return
Expand All @@ -391,7 +391,7 @@ type usersSearch struct {
PageSize int `short:"s" long:"page_size" description:"The size of per page, default is 10." default:"10"`
}

var users_search usersSearch
var usrSearch usersSearch

func (x *usersSearch) Execute(args []string) error {
GetUsersSearch(utils.URLGen("/api/users"))
Expand All @@ -412,10 +412,10 @@ func (x *usersSearch) Execute(args []string) error {
// e.g. curl -X GET --header 'Accept: application/json' 'https://localhost/api/users?username=san.zhang&email=san.zhang@163.com&page=1&page_size=10'
//
func GetUsersSearch(baseURL string) {
targetURL := baseURL + "?username=" + users_search.Username +
"&email=" + users_search.Email +
"&page=" + strconv.Itoa(users_search.Page) +
"&page_size=" + strconv.Itoa(users_search.PageSize)
targetURL := baseURL + "?username=" + usrSearch.Username +
"&email=" + usrSearch.Email +
"&page=" + strconv.Itoa(usrSearch.Page) +
"&page_size=" + strconv.Itoa(usrSearch.PageSize)

fmt.Println("==> GET", targetURL)

Expand All @@ -434,7 +434,7 @@ func GetUsersSearch(baseURL string) {
type userCurrent struct {
}

var user_current userCurrent
var usrCurrent userCurrent

func (x *userCurrent) Execute(args []string) error {
GetUserCurrent(utils.URLGen("/api/users"))
Expand Down
1 change: 1 addition & 0 deletions docs/00_harbor_setup_35_120.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/01_login_whoami_logout_35_120.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/02_version_35_120.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/03_statistics_35_120.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Demonstration

## Setup Harbor Service

<p align="center">
<img src="https://github.com/moooofly/harbor-go-client/blob/develop/docs/00_harbor_setup_35_120.svg">
</p>

## Login-whoami-logout

<p align="center">
<img src="https://github.com/moooofly/harbor-go-client/blob/develop/docs/01_login_whoami_logout_35_120.svg">
</p>

## Version

<p align="center">
<img src="https://github.com/moooofly/harbor-go-client/blob/develop/docs/02_version_35_120.svg">
</p>

## Statistics

<p align="center">
<img src="https://github.com/moooofly/harbor-go-client/blob/develop/docs/03_statistics_35_120.svg">
</p>

0 comments on commit 5dd4268

Please sign in to comment.