Class: Gitlab::Ci::Pipeline::Quota::Deployments

Inherits:
Limit
  • Object
show all
Includes:
ActionView::Helpers::TextHelper, Utils::StrongMemoize
Defined in:
lib/gitlab/ci/pipeline/quota/deployments.rb

Constant Summary

Constants inherited from Limit

Limit::LimitExceededError

Instance Method Summary collapse

Methods inherited from Limit

#log_error!

Constructor Details

#initialize(namespace, pipeline, command) ⇒ Deployments

Returns a new instance of Deployments.



11
12
13
14
15
# File 'lib/gitlab/ci/pipeline/quota/deployments.rb', line 11

def initialize(namespace, pipeline, command)
  @namespace = namespace
  @pipeline = pipeline
  @command = command
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/gitlab/ci/pipeline/quota/deployments.rb', line 17

def enabled?
  limit > 0
end

#exceeded?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/gitlab/ci/pipeline/quota/deployments.rb', line 21

def exceeded?
  return false unless enabled?

  pipeline_deployment_count > limit
end

#messageObject



27
28
29
30
31
# File 'lib/gitlab/ci/pipeline/quota/deployments.rb', line 27

def message
  return unless exceeded?

  "Pipeline has too many deployments! Requested #{pipeline_deployment_count}, but the limit is #{limit}."
end