mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-03 14:37:44 +01:00
Merge pull request #3692 from ywk253100/171127_repo_desc
Add update repository API to support description of repository
This commit is contained in:
commit
5de872486c
@ -961,6 +961,33 @@ paths:
|
|||||||
description: Forbidden.
|
description: Forbidden.
|
||||||
'404':
|
'404':
|
||||||
description: Repository not found.
|
description: Repository not found.
|
||||||
|
put:
|
||||||
|
summary: Update description of the repository.
|
||||||
|
description: |
|
||||||
|
This endpoint is used to update description of the repository.
|
||||||
|
parameters:
|
||||||
|
- name: repo_name
|
||||||
|
in: path
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
description: The name of repository which will be deleted.
|
||||||
|
- name: description
|
||||||
|
in: body
|
||||||
|
description: The description of the repository.
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/RepositoryDescription'
|
||||||
|
tags:
|
||||||
|
- Products
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Update successfully.
|
||||||
|
'401':
|
||||||
|
description: Unauthorized.
|
||||||
|
'403':
|
||||||
|
description: Forbidden.
|
||||||
|
'404':
|
||||||
|
description: Repository not found.
|
||||||
'/repositories/{repo_name}/tags/{tag}':
|
'/repositories/{repo_name}/tags/{tag}':
|
||||||
get:
|
get:
|
||||||
summary: Get the tag of the repository.
|
summary: Get the tag of the repository.
|
||||||
@ -1158,7 +1185,7 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#definitions/VulnerabilityItem'
|
$ref: '#/definitions/VulnerabilityItem'
|
||||||
'401':
|
'401':
|
||||||
description: User needs to login or call the API with correct credentials.
|
description: User needs to login or call the API with correct credentials.
|
||||||
'403':
|
'403':
|
||||||
@ -2920,6 +2947,12 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
description: The offest in seconds of UTC 0 o'clock, only valid when the policy type is "daily"
|
description: The offest in seconds of UTC 0 o'clock, only valid when the policy type is "daily"
|
||||||
description: The parameters of the policy, the values are dependant on the type of the policy.
|
description: The parameters of the policy, the values are dependant on the type of the policy.
|
||||||
|
RepositoryDescription:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
description: The description of the repository.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -605,6 +605,43 @@ func (ra *RepositoryAPI) GetTopRepos() {
|
|||||||
ra.ServeJSON()
|
ra.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Put updates description info for the repository
|
||||||
|
func (ra *RepositoryAPI) Put() {
|
||||||
|
name := ra.GetString(":splat")
|
||||||
|
repository, err := dao.GetRepositoryByName(name)
|
||||||
|
if err != nil {
|
||||||
|
ra.HandleInternalServerError(fmt.Sprintf("failed to get repository %s: %v", name, err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if repository == nil {
|
||||||
|
ra.HandleNotFound(fmt.Sprintf("repository %s not found", name))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !ra.SecurityCtx.IsAuthenticated() {
|
||||||
|
ra.HandleUnauthorized()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
project, _ := utils.ParseRepository(name)
|
||||||
|
if !ra.SecurityCtx.HasAllPerm(project) {
|
||||||
|
ra.HandleForbidden(ra.SecurityCtx.GetUsername())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
desc := struct {
|
||||||
|
Description string `json:"description"`
|
||||||
|
}{}
|
||||||
|
ra.DecodeJSONReq(&desc)
|
||||||
|
|
||||||
|
repository.Description = desc.Description
|
||||||
|
if err = dao.UpdateRepository(*repository); err != nil {
|
||||||
|
ra.HandleInternalServerError(fmt.Sprintf("failed to update repository %s: %v", name, err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//GetSignatures returns signatures of a repository
|
//GetSignatures returns signatures of a repository
|
||||||
func (ra *RepositoryAPI) GetSignatures() {
|
func (ra *RepositoryAPI) GetSignatures() {
|
||||||
repoName := ra.GetString(":splat")
|
repoName := ra.GetString(":splat")
|
||||||
|
@ -93,7 +93,7 @@ func initRouters() {
|
|||||||
beego.Router("/api/internal/syncregistry", &api.InternalAPI{}, "post:SyncRegistry")
|
beego.Router("/api/internal/syncregistry", &api.InternalAPI{}, "post:SyncRegistry")
|
||||||
beego.Router("/api/repositories", &api.RepositoryAPI{}, "get:Get")
|
beego.Router("/api/repositories", &api.RepositoryAPI{}, "get:Get")
|
||||||
beego.Router("/api/repositories/scanAll", &api.RepositoryAPI{}, "post:ScanAll")
|
beego.Router("/api/repositories/scanAll", &api.RepositoryAPI{}, "post:ScanAll")
|
||||||
beego.Router("/api/repositories/*", &api.RepositoryAPI{}, "delete:Delete")
|
beego.Router("/api/repositories/*", &api.RepositoryAPI{}, "delete:Delete;put:Put")
|
||||||
beego.Router("/api/repositories/*/tags/:tag", &api.RepositoryAPI{}, "delete:Delete;get:GetTag")
|
beego.Router("/api/repositories/*/tags/:tag", &api.RepositoryAPI{}, "delete:Delete;get:GetTag")
|
||||||
beego.Router("/api/repositories/*/tags", &api.RepositoryAPI{}, "get:GetTags")
|
beego.Router("/api/repositories/*/tags", &api.RepositoryAPI{}, "get:GetTags")
|
||||||
beego.Router("/api/repositories/*/tags/:tag/scan", &api.RepositoryAPI{}, "post:ScanImage")
|
beego.Router("/api/repositories/*/tags/:tag/scan", &api.RepositoryAPI{}, "post:ScanImage")
|
||||||
|
Loading…
Reference in New Issue
Block a user