BigW Consortium Gitlab

runner_policy.rb 536 Bytes
Newer Older
1 2
module Ci
  class RunnerPolicy < BasePolicy
3 4
    with_options scope: :subject, score: 0
    condition(:shared) { @subject.is_shared? }
5

6 7
    with_options scope: :subject, score: 0
    condition(:locked, scope: :subject) { @subject.locked? }
8

9
    condition(:authorized_runner) { @user.ci_authorized_runners.include?(@subject) }
10

11 12 13 14
    rule { anonymous }.prevent_all
    rule { admin | authorized_runner }.enable :assign_runner
    rule { ~admin & shared }.prevent :assign_runner
    rule { ~admin & locked }.prevent :assign_runner
15 16
  end
end