2016-08-18 12:52:35 -04:00
|
|
|
module Ci
|
|
|
|
class RunnerPolicy < BasePolicy
|
2017-04-06 17:06:42 -04:00
|
|
|
with_options scope: :subject, score: 0
|
|
|
|
condition(:locked, scope: :subject) { @subject.locked? }
|
2016-08-18 12:52:35 -04:00
|
|
|
|
2018-05-10 08:42:55 -04:00
|
|
|
condition(:owned_runner) { @user.ci_owned_runners.exists?(@subject.id) }
|
2016-08-18 12:52:35 -04:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
rule { anonymous }.prevent_all
|
2018-05-10 08:42:55 -04:00
|
|
|
rule { admin | owned_runner }.enable :assign_runner
|
|
|
|
rule { admin | owned_runner }.enable :read_runner
|
|
|
|
rule { admin | owned_runner }.enable :update_runner
|
|
|
|
rule { admin | owned_runner }.enable :delete_runner
|
|
|
|
rule { admin | owned_runner }.enable :list_runner_jobs
|
2017-04-06 17:06:42 -04:00
|
|
|
rule { ~admin & locked }.prevent :assign_runner
|
2016-08-18 12:52:35 -04:00
|
|
|
end
|
|
|
|
end
|