summaryrefslogtreecommitdiff
path: root/app/finders/ci/jobs_finder.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/ci/jobs_finder.rb')
-rw-r--r--app/finders/ci/jobs_finder.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/finders/ci/jobs_finder.rb b/app/finders/ci/jobs_finder.rb
index 4408c9cdb6d..5fc9c0e1778 100644
--- a/app/finders/ci/jobs_finder.rb
+++ b/app/finders/ci/jobs_finder.rb
@@ -4,10 +4,11 @@ module Ci
class JobsFinder
include Gitlab::Allowable
- def initialize(current_user:, pipeline: nil, project: nil, params: {}, type: ::Ci::Build)
+ def initialize(current_user:, pipeline: nil, project: nil, runner: nil, params: {}, type: ::Ci::Build)
@pipeline = pipeline
@current_user = current_user
@project = project
+ @runner = runner
@params = params
@type = type
raise ArgumentError 'type must be a subclass of Ci::Processable' unless type < ::Ci::Processable
@@ -22,10 +23,10 @@ module Ci
private
- attr_reader :current_user, :pipeline, :project, :params, :type
+ attr_reader :current_user, :pipeline, :project, :runner, :params, :type
def init_collection
- pipeline_jobs || project_jobs || all_jobs
+ pipeline_jobs || project_jobs || runner_jobs || all_jobs
end
def all_jobs
@@ -34,6 +35,13 @@ module Ci
type.all
end
+ def runner_jobs
+ return unless runner
+ raise Gitlab::Access::AccessDeniedError unless can?(current_user, :read_builds, runner)
+
+ jobs_by_type(runner, type).relevant
+ end
+
def project_jobs
return unless project
raise Gitlab::Access::AccessDeniedError unless can?(current_user, :read_build, project)