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

20 lines
488 B
Ruby
Raw Normal View History

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
2018-11-08 19:23:39 +05:30
condition(:owned_runner) { @user.ci_owned_runners.exists?(@subject.id) }
2016-09-29 09:46:39 +05:30
2017-09-10 17:25:29 +05:30
rule { anonymous }.prevent_all
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
2017-09-10 17:25:29 +05:30
rule { ~admin & locked }.prevent :assign_runner
2016-09-29 09:46:39 +05:30
end
end