diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-01 18:14:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-01 18:14:27 +0300 |
commit | afbaf78b0d819326741a01b093bdbc4702570417 (patch) | |
tree | a16a6f2a8fcc18e60f25ac72df6ab22cfe0eae79 /app/presenters | |
parent | 38b3003b67db3f2eadfa81fd28b13d168f665766 (diff) |
Add latest changes from gitlab-org/gitlab@13-10-stable-ee
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/packages/composer/packages_presenter.rb | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/app/presenters/packages/composer/packages_presenter.rb b/app/presenters/packages/composer/packages_presenter.rb index 8e3f482126d..2eb9b8910a3 100644 --- a/app/presenters/packages/composer/packages_presenter.rb +++ b/app/presenters/packages/composer/packages_presenter.rb @@ -5,25 +5,35 @@ module Packages class PackagesPresenter include API::Helpers::RelatedResourcesHelpers - def initialize(group, packages) + def initialize(group, packages, is_v2 = false) @group = group @packages = packages + @is_v2 = is_v2 end def root - v1_path = expose_path(api_v4_group___packages_composer_package_name_path({ id: @group.id, package_name: '%package%$%hash%', format: '.json' }, true)) v2_path = expose_path(api_v4_group___packages_composer_p2_package_name_path({ id: @group.id, package_name: '%package%', format: '.json' }, true)) - { + index = { 'packages' => [], + 'metadata-url' => v2_path + } + + # if the client is composer v2 then we don't want to + # include the provider_sha since it is computationally expensive + # to compute. + return index if @is_v2 + + v1_path = expose_path(api_v4_group___packages_composer_package_name_path({ id: @group.id, package_name: '%package%$%hash%', format: '.json' }, true)) + + index.merge!( 'provider-includes' => { 'p/%hash%.json' => { 'sha256' => provider_sha } }, - 'providers-url' => v1_path, - 'metadata-url' => v2_path - } + 'providers-url' => v1_path + ) end def provider |