Welcome to mirror list, hosted at ThFree Co, Russian Federation.

deployment_policy.rb « policies « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 70b2e864094c4786a4bbab43449d3749cf49862d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

class DeploymentPolicy < BasePolicy
  delegate { @subject.project }

  condition(:can_retry_deployable) do
    can?(:update_build, @subject.deployable)
  end

  condition(:has_deployable) do
    @subject.deployable.present?
  end

  condition(:can_update_deployment) do
    can?(:update_deployment, @subject.environment)
  end

  rule { has_deployable & ~can_retry_deployable }.policy do
    prevent :create_deployment
    prevent :update_deployment
  end

  rule { ~can_update_deployment }.policy do
    prevent :update_deployment
  end
end

DeploymentPolicy.prepend_mod_with('DeploymentPolicy')