Class: Packages::Pypi::CreatePackageService

Inherits:
CreatePackageService show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/packages/pypi/create_package_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/packages/pypi/create_package_service.rb', line 8

def execute
  ::Packages::Package.transaction do
    meta = Packages::Pypi::Metadatum.new(
      package: created_package,
      required_python: params[:requires_python]
    )

    unless meta.valid?
      raise ActiveRecord::RecordInvalid.new(meta)
    end

    Packages::Pypi::Metadatum.upsert(meta.attributes)

    ::Packages::CreatePackageFileService.new(created_package, file_params).execute
  end
end