From bcf81224ad99d49c27ff7fed9607c9697c93c51f Mon Sep 17 00:00:00 2001 From: Wenkai Yin Date: Wed, 14 Mar 2018 13:42:19 +0800 Subject: [PATCH] Update according to the comments --- docs/swagger.yaml | 20 ++++++++++++++------ make/photon/db/registry.sql | 3 +++ make/photon/db/registry_sqlite.sql | 5 +++++ src/ui/router.go | 6 +++--- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 898a83af1..682a59128 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1011,10 +1011,14 @@ paths: responses: '200': description: Successfully. + schema: + type: array + items: + $ref: '#/definitions/Label' '401': description: Unauthorized. '403': - description: Forbidden. + description: Forbidden. User should have read permisson for the repository to perform the action. '404': description: Repository not found. post: @@ -1041,7 +1045,7 @@ paths: '401': description: Unauthorized. '403': - description: Forbidden. + description: Forbidden. User should have write permisson for the repository to perform the action. '404': description: Resource not found. '/repositories/{repo_name}/labels/{label_id}': @@ -1068,7 +1072,7 @@ paths: '401': description: Unauthorized. '403': - description: Forbidden. + description: Forbidden. User should have write permisson for the repository to perform the action. '404': description: Resource not found. '/repositories/{repo_name}/tags/{tag}': @@ -1172,10 +1176,14 @@ paths: responses: '200': description: Successfully. + schema: + type: array + items: + $ref: '#/definitions/Label' '401': description: Unauthorized. '403': - description: Forbidden. + description: Forbidden. User should have read permisson for the image to perform the action. '404': description: Resource not found. post: @@ -1207,7 +1215,7 @@ paths: '401': description: Unauthorized. '403': - description: Forbidden. + description: Forbidden. User should have write permisson for the image to perform the action. '404': description: Resource not found. '/repositories/{repo_name}/tags/{tag}/labels/{label_id}': @@ -1239,7 +1247,7 @@ paths: '401': description: Unauthorized. '403': - description: Forbidden. + description: Forbidden. User should have write permisson for the image to perform the action. '404': description: Resource not found. '/repositories/{repo_name}/tags/{tag}/manifest': diff --git a/make/photon/db/registry.sql b/make/photon/db/registry.sql index c6d450452..02e96d663 100644 --- a/make/photon/db/registry.sql +++ b/make/photon/db/registry.sql @@ -275,6 +275,9 @@ create table harbor_label ( create table harbor_resource_label ( id int NOT NULL AUTO_INCREMENT, label_id int NOT NULL, +# the resource_id is the ID of project when the resource_type is p +# the resource_id is the ID of repository when the resource_type is r +# the resource_id is the name of image when the resource_type is i resource_id varchar(256) NOT NULL, # 'p' for project # 'r' for repository diff --git a/make/photon/db/registry_sqlite.sql b/make/photon/db/registry_sqlite.sql index b870ff9f7..5d045edb0 100644 --- a/make/photon/db/registry_sqlite.sql +++ b/make/photon/db/registry_sqlite.sql @@ -264,6 +264,11 @@ create table harbor_label ( create table harbor_resource_label ( id INTEGER PRIMARY KEY, label_id int NOT NULL, +/* + the resource_id is the ID of project when the resource_type is p + the resource_id is the ID of repository when the resource_type is r + the resource_id is the name of image when the resource_type is i +*/ resource_id varchar(256) NOT NULL, /* 'p' for project diff --git a/src/ui/router.go b/src/ui/router.go index 84437ba77..d6a722d6a 100644 --- a/src/ui/router.go +++ b/src/ui/router.go @@ -71,10 +71,10 @@ func initRouters() { beego.Router("/api/repositories/scanAll", &api.RepositoryAPI{}, "post:ScanAll") beego.Router("/api/repositories/*", &api.RepositoryAPI{}, "delete:Delete;put:Put") beego.Router("/api/repositories/*/labels", &api.RepositoryLabelAPI{}, "get:GetOfRepository;post:AddToRepository") - beego.Router("/api/repositories/*/labels/:id([0-9]+", &api.RepositoryLabelAPI{}, "delete:RemoveFromRepository") + beego.Router("/api/repositories/*/labels/:id([0-9]+)", &api.RepositoryLabelAPI{}, "delete:RemoveFromRepository") beego.Router("/api/repositories/*/tags/:tag", &api.RepositoryAPI{}, "delete:Delete;get:GetTag") beego.Router("/api/repositories/*/tags/:tag/labels", &api.RepositoryLabelAPI{}, "get:GetOfImage;post:AddToImage") - beego.Router("/api/repositories/*/tags/:tag/labels/:id([0-9]+", &api.RepositoryLabelAPI{}, "delete:RemoveFromImage") + beego.Router("/api/repositories/*/tags/:tag/labels/:id([0-9]+)", &api.RepositoryLabelAPI{}, "delete:RemoveFromImage") 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/vulnerability/details", &api.RepositoryAPI{}, "Get:VulnerabilityDetails") @@ -99,7 +99,7 @@ func initRouters() { beego.Router("/api/statistics", &api.StatisticAPI{}) beego.Router("/api/replications", &api.ReplicationAPI{}) beego.Router("/api/labels", &api.LabelAPI{}, "post:Post;get:List") - beego.Router("/api/labels/:id([0-9]+", &api.LabelAPI{}, "get:Get;put:Put;delete:Delete") + beego.Router("/api/labels/:id([0-9]+)", &api.LabelAPI{}, "get:Get;put:Put;delete:Delete") beego.Router("/api/systeminfo", &api.SystemInfoAPI{}, "get:GetGeneralInfo") beego.Router("/api/systeminfo/volumes", &api.SystemInfoAPI{}, "get:GetVolumeInfo")