diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /app/presenters/packages | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/presenters/packages')
-rw-r--r-- | app/presenters/packages/helm/index_presenter.rb | 53 | ||||
-rw-r--r-- | app/presenters/packages/nuget/presenter_helpers.rb | 3 | ||||
-rw-r--r-- | app/presenters/packages/nuget/service_index_presenter.rb | 10 |
3 files changed, 64 insertions, 2 deletions
diff --git a/app/presenters/packages/helm/index_presenter.rb b/app/presenters/packages/helm/index_presenter.rb new file mode 100644 index 00000000000..a6cfc61c94d --- /dev/null +++ b/app/presenters/packages/helm/index_presenter.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +module Packages + module Helm + class IndexPresenter + include API::Helpers::RelatedResourcesHelpers + + API_VERSION = 'v1' + CHANNEL = 'channel' + INDEX_YAML_SUFFIX = "/#{CHANNEL}/index.yaml" + + def initialize(project, project_id_param, package_files) + @project = project + @project_id_param = project_id_param + @package_files = package_files + end + + def api_version + API_VERSION + end + + def entries + files = @package_files.preload_helm_file_metadata + result = Hash.new { |h, k| h[k] = [] } + + files.find_each do |package_file| + name = package_file.helm_metadata['name'] + result[name] << package_file.helm_metadata.merge({ + 'created' => package_file.created_at.utc.strftime('%Y-%m-%dT%H:%M:%S.%NZ'), + 'digest' => package_file.file_sha256, + 'urls' => ["charts/#{package_file.file_name}"] + }) + end + + result + end + + def generated + Time.zone.now.utc.strftime('%Y-%m-%dT%H:%M:%S.%NZ') + end + + def server_info + path = api_v4_projects_packages_helm_index_yaml_path( + id: ERB::Util.url_encode(@project_id_param), + channel: CHANNEL + ) + { + 'contextPath' => path.delete_suffix(INDEX_YAML_SUFFIX) + } + end + end + end +end diff --git a/app/presenters/packages/nuget/presenter_helpers.rb b/app/presenters/packages/nuget/presenter_helpers.rb index cc7e8619220..09bf1e009a6 100644 --- a/app/presenters/packages/nuget/presenter_helpers.rb +++ b/app/presenters/packages/nuget/presenter_helpers.rb @@ -8,6 +8,7 @@ module Packages BLANK_STRING = '' PACKAGE_DEPENDENCY_GROUP = 'PackageDependencyGroup' PACKAGE_DEPENDENCY = 'PackageDependency' + NUGET_PACKAGE_FORMAT = 'nupkg' private @@ -31,7 +32,7 @@ module Packages id: package.project_id, package_name: package.name, package_version: package.version, - package_filename: package.package_files.last&.file_name + package_filename: package.package_files.with_format(NUGET_PACKAGE_FORMAT).last&.file_name }, true ) diff --git a/app/presenters/packages/nuget/service_index_presenter.rb b/app/presenters/packages/nuget/service_index_presenter.rb index b3cc912b811..033a1845c1c 100644 --- a/app/presenters/packages/nuget/service_index_presenter.rb +++ b/app/presenters/packages/nuget/service_index_presenter.rb @@ -8,6 +8,7 @@ module Packages SERVICE_VERSIONS = { download: %w[PackageBaseAddress/3.0.0], search: %w[SearchQueryService SearchQueryService/3.0.0-beta SearchQueryService/3.0.0-rc], + symbol: %w[SymbolPackagePublish/4.9.0], publish: %w[PackagePublish/2.0.0], metadata: %w[RegistrationsBaseUrl RegistrationsBaseUrl/3.0.0-beta RegistrationsBaseUrl/3.0.0-rc] }.freeze @@ -15,13 +16,14 @@ module Packages SERVICE_COMMENTS = { download: 'Get package content (.nupkg).', search: 'Filter and search for packages by keyword.', + symbol: 'Push symbol packages.', publish: 'Push and delete (or unlist) packages.', metadata: 'Get package metadata.' }.freeze VERSION = '3.0.0' - PROJECT_LEVEL_SERVICES = %i[download publish].freeze + PROJECT_LEVEL_SERVICES = %i[download publish symbol].freeze GROUP_LEVEL_SERVICES = %i[search metadata].freeze def initialize(project_or_group) @@ -63,6 +65,8 @@ module Packages download_service_url when :search search_service_url + when :symbol + symbol_service_url when :metadata metadata_service_url when :publish @@ -124,6 +128,10 @@ module Packages def publish_service_url api_v4_projects_packages_nuget_path(id: @project_or_group.id) end + + def symbol_service_url + api_v4_projects_packages_nuget_symbolpackage_path(id: @project_or_group.id) + end end end end |