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

28 lines
581 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
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
2017-09-10 17:25:29 +05:30
rule { ~admin & locked }.prevent :assign_runner
2016-09-29 09:46:39 +05:30
end
end