Skip to content

Commit

Permalink
fix(api): getWorkflowJobQueueHandler filter by group for all hatcheri…
Browse files Browse the repository at this point in the history
…es (#5079)

Signed-off-by: francois  samin <[email protected]>
  • Loading branch information
fsamin authored Mar 25, 2020
1 parent 4feb0fe commit 8a6f308
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions engine/api/workflow_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,12 +741,12 @@ func (api *API) getWorkflowJobQueueHandler() service.Handler {
return errM
}

permissions := sdk.PermissionReadExecute
permissions := sdk.PermissionRead

isW := isWorker(ctx)
isS := isService(ctx)
if !isW && !isS {
permissions = sdk.PermissionRead
if isW || isS {
permissions = sdk.PermissionReadExecute
}

filter := workflow.NewQueueFilter()
Expand All @@ -759,8 +759,10 @@ func (api *API) getWorkflowJobQueueHandler() service.Handler {
if modelType != "" {
filter.ModelType = []string{modelType}
}

var jobs []sdk.WorkflowNodeJobRun
if !isMaintainer(ctx) && !isAdmin(ctx) {
// If the consumer is a worker, a hatchery or a non maintainer user, filter the job by its groups
if isW || isS || !isMaintainer(ctx) {
jobs, err = workflow.LoadNodeJobRunQueueByGroupIDs(ctx, api.mustDB(), api.Cache, filter, getAPIConsumer(ctx).GetGroupIDs())
} else {
jobs, err = workflow.LoadNodeJobRunQueue(ctx, api.mustDB(), api.Cache, filter)
Expand Down

0 comments on commit 8a6f308

Please sign in to comment.