debian-mirror-gitlab/app/policies/ci/runner_policy.rb

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

36 lines
817 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-09-29 09:46:39 +05:30
module Ci
class RunnerPolicy < BasePolicy
2017-09-10 17:25:29 +05:30
with_options scope: :subject, score: 0
condition(:locked, scope: :subject) { @subject.locked? }
2016-09-29 09:46:39 +05:30
2021-11-11 11:23:49 +05:30
condition(:owned_runner) do
@user.owns_runner?(@subject)
end
2016-09-29 09:46:39 +05:30
2022-05-07 20:08:51 +05:30
condition(:belongs_to_multiple_projects) do
@subject.belongs_to_more_than_one_project?
end
2017-09-10 17:25:29 +05:30
rule { anonymous }.prevent_all
2018-11-08 19:23:39 +05:30
2022-04-04 11:22:00 +05:30
rule { admin }.policy do
enable :read_builds
end
2018-11-08 19:23:39 +05:30
rule { admin | owned_runner }.policy do
enable :assign_runner
enable :read_runner
enable :update_runner
enable :delete_runner
end
2022-05-07 20:08:51 +05:30
rule { ~admin & belongs_to_multiple_projects }.prevent :delete_runner
2017-09-10 17:25:29 +05:30
rule { ~admin & locked }.prevent :assign_runner
2016-09-29 09:46:39 +05:30
end
end
2022-08-27 11:52:29 +05:30
Ci::RunnerPolicy.prepend_mod_with('Ci::RunnerPolicy')