Class: Gitlab::Checks::TagCheck

Inherits:
BaseChecker show all
Defined in:
lib/gitlab/checks/tag_check.rb

Constant Summary collapse

ERROR_MESSAGES =
{
  change_existing_tags: 'You are not allowed to change existing tags on this project.',
  update_protected_tag: 'Protected tags cannot be updated.',
  delete_protected_tag: 'Protected tags cannot be deleted.',
  create_protected_tag: 'You are not allowed to create this tag as it is protected.'
}.freeze
LOG_MESSAGES =
{
  tag_checks: "Checking if you are allowed to change existing tags...",
  protected_tag_checks: "Checking if you are creating, updating or deleting a protected tag..."
}.freeze

Instance Attribute Summary

Attributes inherited from BaseChecker

#change_access

Instance Method Summary collapse

Methods inherited from BaseChecker

#initialize

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

This class inherits a constructor from Gitlab::Checks::BaseChecker

Instance Method Details

#validate!Object


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/checks/tag_check.rb', line 18

def validate!
  return unless tag_name

  logger.log_timed(LOG_MESSAGES[:tag_checks]) do
    if tag_exists? && user_access.cannot_do_action?(:admin_tag)
      raise GitAccess::ForbiddenError, ERROR_MESSAGES[:change_existing_tags]
    end
  end

  protected_tag_checks
end