mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 13:45:20 +01:00
Use project controller rather than the manager in API handlers (#10946)
Use project controller rather than the manager in API handlers Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
parent
84bd30c570
commit
d21318dfcf
@ -32,7 +32,6 @@ import (
|
|||||||
"github.com/goharbor/harbor/src/common/rbac"
|
"github.com/goharbor/harbor/src/common/rbac"
|
||||||
"github.com/goharbor/harbor/src/common/utils"
|
"github.com/goharbor/harbor/src/common/utils"
|
||||||
ierror "github.com/goharbor/harbor/src/internal/error"
|
ierror "github.com/goharbor/harbor/src/internal/error"
|
||||||
"github.com/goharbor/harbor/src/pkg/project"
|
|
||||||
"github.com/goharbor/harbor/src/pkg/q"
|
"github.com/goharbor/harbor/src/pkg/q"
|
||||||
v1 "github.com/goharbor/harbor/src/pkg/scan/rest/v1"
|
v1 "github.com/goharbor/harbor/src/pkg/scan/rest/v1"
|
||||||
"github.com/goharbor/harbor/src/server/v2.0/handler/assembler"
|
"github.com/goharbor/harbor/src/server/v2.0/handler/assembler"
|
||||||
@ -48,7 +47,6 @@ const (
|
|||||||
func newArtifactAPI() *artifactAPI {
|
func newArtifactAPI() *artifactAPI {
|
||||||
return &artifactAPI{
|
return &artifactAPI{
|
||||||
artCtl: artifact.Ctl,
|
artCtl: artifact.Ctl,
|
||||||
proMgr: project.Mgr,
|
|
||||||
repoCtl: repository.Ctl,
|
repoCtl: repository.Ctl,
|
||||||
scanCtl: scan.DefaultController,
|
scanCtl: scan.DefaultController,
|
||||||
tagCtl: tag.Ctl,
|
tagCtl: tag.Ctl,
|
||||||
@ -58,7 +56,6 @@ func newArtifactAPI() *artifactAPI {
|
|||||||
type artifactAPI struct {
|
type artifactAPI struct {
|
||||||
BaseAPI
|
BaseAPI
|
||||||
artCtl artifact.Controller
|
artCtl artifact.Controller
|
||||||
proMgr project.Manager
|
|
||||||
repoCtl repository.Controller
|
repoCtl repository.Controller
|
||||||
scanCtl scan.Controller
|
scanCtl scan.Controller
|
||||||
tagCtl tag.Controller
|
tagCtl tag.Controller
|
||||||
|
@ -19,11 +19,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-openapi/runtime/middleware"
|
"github.com/go-openapi/runtime/middleware"
|
||||||
"github.com/goharbor/harbor/src/api/artifact"
|
"github.com/goharbor/harbor/src/api/artifact"
|
||||||
|
"github.com/goharbor/harbor/src/api/project"
|
||||||
"github.com/goharbor/harbor/src/api/repository"
|
"github.com/goharbor/harbor/src/api/repository"
|
||||||
cmodels "github.com/goharbor/harbor/src/common/models"
|
cmodels "github.com/goharbor/harbor/src/common/models"
|
||||||
"github.com/goharbor/harbor/src/common/rbac"
|
"github.com/goharbor/harbor/src/common/rbac"
|
||||||
"github.com/goharbor/harbor/src/common/utils/log"
|
"github.com/goharbor/harbor/src/common/utils/log"
|
||||||
"github.com/goharbor/harbor/src/pkg/project"
|
|
||||||
"github.com/goharbor/harbor/src/pkg/q"
|
"github.com/goharbor/harbor/src/pkg/q"
|
||||||
"github.com/goharbor/harbor/src/server/v2.0/models"
|
"github.com/goharbor/harbor/src/server/v2.0/models"
|
||||||
operation "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/repository"
|
operation "github.com/goharbor/harbor/src/server/v2.0/restapi/operations/repository"
|
||||||
@ -31,7 +31,7 @@ import (
|
|||||||
|
|
||||||
func newRepositoryAPI() *repositoryAPI {
|
func newRepositoryAPI() *repositoryAPI {
|
||||||
return &repositoryAPI{
|
return &repositoryAPI{
|
||||||
proMgr: project.Mgr,
|
proCtl: project.Ctl,
|
||||||
repoCtl: repository.Ctl,
|
repoCtl: repository.Ctl,
|
||||||
artCtl: artifact.Ctl,
|
artCtl: artifact.Ctl,
|
||||||
}
|
}
|
||||||
@ -39,8 +39,7 @@ func newRepositoryAPI() *repositoryAPI {
|
|||||||
|
|
||||||
type repositoryAPI struct {
|
type repositoryAPI struct {
|
||||||
BaseAPI
|
BaseAPI
|
||||||
// TODO replace proMgr with proCtl
|
proCtl project.Controller
|
||||||
proMgr project.Manager
|
|
||||||
repoCtl repository.Controller
|
repoCtl repository.Controller
|
||||||
artCtl artifact.Controller
|
artCtl artifact.Controller
|
||||||
}
|
}
|
||||||
@ -49,7 +48,7 @@ func (r *repositoryAPI) ListRepositories(ctx context.Context, params operation.L
|
|||||||
if err := r.RequireProjectAccess(ctx, params.ProjectName, rbac.ActionList, rbac.ResourceRepository); err != nil {
|
if err := r.RequireProjectAccess(ctx, params.ProjectName, rbac.ActionList, rbac.ResourceRepository); err != nil {
|
||||||
return r.SendError(ctx, err)
|
return r.SendError(ctx, err)
|
||||||
}
|
}
|
||||||
project, err := r.proMgr.Get(params.ProjectName)
|
project, err := r.proCtl.GetByName(ctx, params.ProjectName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendError(ctx, err)
|
return r.SendError(ctx, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user