diff options
Diffstat (limited to 'app/finders/ci')
-rw-r--r-- | app/finders/ci/jobs_finder.rb | 14 | ||||
-rw-r--r-- | app/finders/ci/runners_finder.rb | 10 |
2 files changed, 13 insertions, 11 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) diff --git a/app/finders/ci/runners_finder.rb b/app/finders/ci/runners_finder.rb index 3ebf6bd1562..356915722fe 100644 --- a/app/finders/ci/runners_finder.rb +++ b/app/finders/ci/runners_finder.rb @@ -4,7 +4,7 @@ module Ci class RunnersFinder < UnionFinder include Gitlab::Allowable - ALLOWED_SORTS = %w[contacted_asc contacted_desc created_at_asc created_at_desc created_date].freeze + ALLOWED_SORTS = %w[contacted_asc contacted_desc created_at_asc created_at_desc created_date token_expires_at_asc token_expires_at_desc].freeze DEFAULT_SORT = 'created_at_desc' def initialize(current_user:, params:) @@ -53,13 +53,7 @@ module Ci when :direct Ci::Runner.belonging_to_group(@group.id) when :descendants, nil - if ::Feature.enabled?(:ci_find_runners_by_ci_mirrors, @group, default_enabled: :yaml) - Ci::Runner.belonging_to_group_or_project_descendants(@group.id) - else - # Getting all runners from the group itself and all its descendant groups/projects - descendant_projects = Project.for_group_and_its_subgroups(@group) - Ci::Runner.legacy_belonging_to_group_or_project(@group.self_and_descendants, descendant_projects) - end + Ci::Runner.belonging_to_group_or_project_descendants(@group.id) else raise ArgumentError, 'Invalid membership filter' end |