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

33 lines
952 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module Ci
class PipelineSchedulePolicy < PipelinePolicy
2017-09-10 17:25:29 +05:30
alias_method :pipeline_schedule, :subject
2018-03-17 18:26:18 +05:30
condition(:protected_ref) do
ref_protected?(@user, @subject.project, @subject.project.repository.tag_exists?(@subject.ref), @subject.ref)
end
2017-09-10 17:25:29 +05:30
condition(:owner_of_schedule) do
2018-05-09 12:01:36 +05:30
pipeline_schedule.owned_by?(@user)
2017-09-10 17:25:29 +05:30
end
2018-05-09 12:01:36 +05:30
rule { can?(:create_pipeline) }.enable :play_pipeline_schedule
2018-03-17 18:26:18 +05:30
2018-05-09 12:01:36 +05:30
rule { can?(:admin_pipeline) | (can?(:update_build) & owner_of_schedule) }.policy do
2017-09-10 17:25:29 +05:30
enable :admin_pipeline_schedule
2020-11-05 12:06:23 +05:30
enable :read_pipeline_schedule_variables
2017-09-10 17:25:29 +05:30
end
2018-03-17 18:26:18 +05:30
2022-05-03 16:02:30 +05:30
rule { admin | (owner_of_schedule & can?(:update_build)) }.policy do
enable :update_pipeline_schedule
end
2018-05-09 12:01:36 +05:30
rule { can?(:admin_pipeline_schedule) & ~owner_of_schedule }.policy do
2018-03-17 18:26:18 +05:30
enable :take_ownership_pipeline_schedule
end
rule { protected_ref }.prevent :play_pipeline_schedule
2017-08-17 22:00:37 +05:30
end
end