Class: Mutations::ContainerRepositories::DestroyTags

Inherits:
DestroyBase
  • Object
show all
Defined in:
app/graphql/mutations/container_repositories/destroy_tags.rb

Constant Summary collapse

LIMIT =
20
TOO_MANY_TAGS_ERROR_MESSAGE =
"Number of tags is greater than #{LIMIT}"

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods inherited from BaseMutation

#api_user?, authorization, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #ready?, #unauthorized_object

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!

Instance Method Details

#resolve(id:, tag_names:) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/graphql/mutations/container_repositories/destroy_tags.rb', line 33

def resolve(id:, tag_names:)
  container_repository = authorized_find!(id: id)

  result = ::Projects::ContainerRepository::DeleteTagsService
    .new(container_repository.project, current_user, tags: tag_names)
    .execute(container_repository)

  track_event(:delete_tag_bulk, :tag) if result[:status] == :success

  {
    errors: Array(result[:message]),
    deleted_tag_names: result[:deleted] || []
  }
end