diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-24 12:11:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-24 12:11:03 +0300 |
commit | fda0e422a7804d541454d86b50113645d8d516f8 (patch) | |
tree | d9aa72a6190d689a424aab28fcfecc643baa48af /lib | |
parent | 4bb7b91adff0cc7e4e7417bf2fc50f9c5cf6e173 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities/package.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/ci/variables/collection/item.rb | 5 | ||||
-rw-r--r-- | lib/gitlab/url_builder.rb | 13 |
3 files changed, 18 insertions, 9 deletions
diff --git a/lib/api/entities/package.rb b/lib/api/entities/package.rb index 18fc0576dd4..9b73a142fcd 100644 --- a/lib/api/entities/package.rb +++ b/lib/api/entities/package.rb @@ -4,6 +4,7 @@ module API module Entities class Package < Grape::Entity include ::API::Helpers::RelatedResourcesHelpers + include ::Routing::PackagesHelper extend ::API::Entities::EntityHelpers expose :id @@ -25,12 +26,8 @@ module API expose :status expose :_links do - expose :web_path do |package, opts| - if package.infrastructure_package? - ::Gitlab::Routing.url_helpers.namespace_project_infrastructure_registry_path(opts[:namespace], package.project, package) - else - ::Gitlab::Routing.url_helpers.project_package_path(package.project, package) - end + expose :web_path do |package| + package_path(package) end expose :delete_api_path, if: can_destroy(:package, &:project) do |package| diff --git a/lib/gitlab/ci/variables/collection/item.rb b/lib/gitlab/ci/variables/collection/item.rb index ea2aa8f2db8..45faf4f63eb 100644 --- a/lib/gitlab/ci/variables/collection/item.rb +++ b/lib/gitlab/ci/variables/collection/item.rb @@ -48,9 +48,8 @@ module Gitlab end ## - # If `file: true` has been provided we expose it, otherwise we - # don't expose `file` attribute at all (stems from what the runner - # expects). + # If `file: true` or `raw: true` has been provided we expose it, otherwise we + # don't expose `file` and `raw` attributes at all (stems from what the runner expects). # def to_runner_variable @variable.reject do |hash_key, hash_value| diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb index a6d6cffec17..e203fb486e7 100644 --- a/lib/gitlab/url_builder.rb +++ b/lib/gitlab/url_builder.rb @@ -52,6 +52,8 @@ module Gitlab wiki_page_url(object.wiki, object, **options) when ::DesignManagement::Design design_url(object, **options) + when ::Packages::Package + package_url(object, **options) else raise NotImplementedError, "No URL builder defined for #{object.inspect}" end @@ -133,6 +135,17 @@ module Gitlab instance.project_design_management_designs_raw_image_url(design.project, design, ref, **options) end end + + def package_url(package, **options) + project = package.project + + if package.infrastructure_package? + return instance.project_infrastructure_registry_url(project, package, +**options) + end + + instance.project_package_url(project, package, **options) + end end end end |