Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /lib/api/helm_packages.rb
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'lib/api/helm_packages.rb')
-rw-r--r--lib/api/helm_packages.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/api/helm_packages.rb b/lib/api/helm_packages.rb
new file mode 100644
index 00000000000..dc5630a1395
--- /dev/null
+++ b/lib/api/helm_packages.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+###
+# API endpoints for the Helm package registry
+module API
+ class HelmPackages < ::API::Base
+ helpers ::API::Helpers::PackagesHelpers
+ helpers ::API::Helpers::Packages::BasicAuthHelpers
+ include ::API::Helpers::Authentication
+
+ feature_category :package_registry
+
+ FILE_NAME_REQUIREMENTS = {
+ file_name: API::NO_SLASH_URL_PART_REGEX
+ }.freeze
+
+ content_type :binary, 'application/octet-stream'
+
+ authenticate_with do |accept|
+ accept.token_types(:personal_access_token, :deploy_token, :job_token)
+ .sent_through(:http_basic_auth)
+ end
+
+ before do
+ require_packages_enabled!
+ end
+
+ after_validation do
+ not_found! unless Feature.enabled?(:helm_packages, authorized_user_project)
+ end
+
+ params do
+ requires :id, type: String, desc: 'The ID or full path of a project'
+ end
+ resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
+ namespace ':id/packages/helm' do
+ desc 'Download a chart' do
+ detail 'This feature was introduced in GitLab 14.0'
+ end
+ params do
+ requires :channel, type: String, desc: 'Helm channel', regexp: Gitlab::Regex.helm_channel_regex
+ requires :file_name, type: String, desc: 'Helm package file name'
+ end
+ get ":channel/charts/:file_name.tgz", requirements: FILE_NAME_REQUIREMENTS do
+ authorize_read_package!(authorized_user_project)
+
+ package_file = Packages::Helm::PackageFilesFinder.new(authorized_user_project, params[:channel], file_name: "#{params[:file_name]}.tgz").execute.last!
+
+ track_package_event('pull_package', :helm, project: authorized_user_project, namespace: authorized_user_project.namespace)
+
+ present_carrierwave_file!(package_file.file)
+ end
+ end
+ end
+ end
+end