Class: Gitlab::Checks::TagCheck

Inherits:
BaseSingleChecker 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: 'You are not allowed to delete protected tags from this project. '\
    'Only a project maintainer or owner can delete a protected tag.',
  delete_protected_tag_non_web: 'You can only delete protected tags using the web interface.',
  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 BaseSingleChecker

#change_access

Instance Method Summary collapse

Methods inherited from BaseSingleChecker

#initialize

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

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

Instance Method Details

#validate!Object


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

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