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

deployments.rb « limit « chain « pipeline « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d684eedcaac67e868645372e26e1cdc4c39bb858 (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
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

module Gitlab
  module Ci
    module Pipeline
      module Chain
        module Limit
          class Deployments < Chain::Base
            extend ::Gitlab::Utils::Override
            include ::Gitlab::Ci::Pipeline::Chain::Helpers

            attr_reader :limit
            private :limit

            def initialize(*)
              super

              @limit = ::Gitlab::Ci::Pipeline::Quota::Deployments
                .new(project.namespace, pipeline, command)
            end

            override :perform!
            def perform!
              return unless limit.exceeded?

              limit.log_error!(project_id: project.id, plan: project.actual_plan_name)
              error(limit.message, drop_reason: :deployments_limit_exceeded)
            end

            override :break?
            def break?
              limit.exceeded?
            end
          end
        end
      end
    end
  end
end