mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-25 19:56:09 +01:00
verify permission of GetRetentionExecTaskLog
Signed-off-by: Ziming Zhang <zziming@vmware.com> Change-Id: I4bf4ddf3d3ed6f07a4618e242e2f3774996716d6 Signed-off-by: Ziming Zhang <zziming@vmware.com>
This commit is contained in:
parent
db5781bf78
commit
8fb6e2f65b
@ -380,11 +380,24 @@ func (r *RetentionAPI) ListRetentionExecTasks() {
|
|||||||
|
|
||||||
// GetRetentionExecTaskLog Get Retention Execution Task log
|
// GetRetentionExecTaskLog Get Retention Execution Task log
|
||||||
func (r *RetentionAPI) GetRetentionExecTaskLog() {
|
func (r *RetentionAPI) GetRetentionExecTaskLog() {
|
||||||
|
id, err := r.GetIDFromURL()
|
||||||
|
if err != nil {
|
||||||
|
r.SendBadRequestError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
tid, err := r.GetInt64FromPath(":tid")
|
tid, err := r.GetInt64FromPath(":tid")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.SendBadRequestError(err)
|
r.SendBadRequestError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
p, err := retentionController.GetRetention(id)
|
||||||
|
if err != nil {
|
||||||
|
r.SendBadRequestError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !r.requireAccess(p, rbac.ActionRead) {
|
||||||
|
return
|
||||||
|
}
|
||||||
log, err := retentionController.GetRetentionExecTaskLog(tid)
|
log, err := retentionController.GetRetentionExecTaskLog(tid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.SendInternalServerError(err)
|
r.SendInternalServerError(err)
|
||||||
|
@ -18,7 +18,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/goharbor/harbor/src/jobservice/job"
|
|
||||||
"github.com/goharbor/harbor/src/pkg/project"
|
"github.com/goharbor/harbor/src/pkg/project"
|
||||||
"github.com/goharbor/harbor/src/pkg/repository"
|
"github.com/goharbor/harbor/src/pkg/repository"
|
||||||
"github.com/goharbor/harbor/src/pkg/retention/policy"
|
"github.com/goharbor/harbor/src/pkg/retention/policy"
|
||||||
@ -28,16 +27,6 @@ import (
|
|||||||
|
|
||||||
// APIController to handle the requests related with retention
|
// APIController to handle the requests related with retention
|
||||||
type APIController interface {
|
type APIController interface {
|
||||||
// Handle the related hooks from the job service and launch the corresponding actions if needed
|
|
||||||
//
|
|
||||||
// Arguments:
|
|
||||||
// PolicyID string : uuid of the retention policy
|
|
||||||
// event *job.StatusChange : event object sent by job service
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// common error object if any errors occurred
|
|
||||||
HandleHook(policyID string, event *job.StatusChange) error
|
|
||||||
|
|
||||||
GetRetention(id int64) (*policy.Metadata, error)
|
GetRetention(id int64) (*policy.Metadata, error)
|
||||||
|
|
||||||
CreateRetention(p *policy.Metadata) (int64, error)
|
CreateRetention(p *policy.Metadata) (int64, error)
|
||||||
@ -263,11 +252,6 @@ func (r *DefaultAPIController) GetRetentionExecTaskLog(taskID int64) ([]byte, er
|
|||||||
return r.manager.GetTaskLog(taskID)
|
return r.manager.GetTaskLog(taskID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleHook HandleHook
|
|
||||||
func (r *DefaultAPIController) HandleHook(policyID string, event *job.StatusChange) error {
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewAPIController ...
|
// NewAPIController ...
|
||||||
func NewAPIController(retentionMgr Manager, projectManager project.Manager, repositoryMgr repository.Manager, scheduler scheduler.Scheduler, retentionLauncher Launcher) APIController {
|
func NewAPIController(retentionMgr Manager, projectManager project.Manager, repositoryMgr repository.Manager, scheduler scheduler.Scheduler, retentionLauncher Launcher) APIController {
|
||||||
return &DefaultAPIController{
|
return &DefaultAPIController{
|
||||||
|
Loading…
Reference in New Issue
Block a user