debian-mirror-gitlab/lib/api/entities/ci/runner_details.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.2 KiB
Ruby
Raw Normal View History

2021-09-30 23:02:18 +05:30
# frozen_string_literal: true
module API
module Entities
module Ci
class RunnerDetails < Runner
expose :tag_list
expose :run_untagged
expose :locked
expose :maximum_timeout
expose :access_level
expose :version, :revision, :platform, :architecture
expose :contacted_at
# rubocop: disable CodeReuse/ActiveRecord
expose :projects, with: Entities::BasicProjectDetails do |runner, options|
2023-03-04 22:38:38 +05:30
if options[:current_user].can_read_all_resources?
2022-04-04 11:22:00 +05:30
runner.projects
2021-09-30 23:02:18 +05:30
else
2022-04-04 11:22:00 +05:30
options[:current_user].authorized_projects.where(id: runner.runner_projects.pluck(:project_id))
2021-09-30 23:02:18 +05:30
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
expose :groups, with: Entities::BasicGroupDetails do |runner, options|
2023-03-04 22:38:38 +05:30
if options[:current_user].can_read_all_resources?
2022-04-04 11:22:00 +05:30
runner.groups
2021-09-30 23:02:18 +05:30
else
2022-04-04 11:22:00 +05:30
options[:current_user].authorized_groups.where(id: runner.runner_namespaces.pluck(:namespace_id))
2021-09-30 23:02:18 +05:30
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
end