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
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-28 12:10:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-28 12:10:41 +0300
commit39ad3270a113f57b63095bfa192a14eb6995236c (patch)
treeebb482b23f90cbeb0aa0e80a5d93577a558c1f86 /lib
parentd193734fb97510ffc55f84c2f3a0a3692cd2d859 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/api.rb1
-rw-r--r--lib/api/helm_packages.rb56
-rw-r--r--lib/gitlab/usage_data_counters/counter_events/package_events.yml1
-rw-r--r--lib/gitlab/usage_data_counters/known_events/package_events.yml8
4 files changed, 66 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb
index 54e5cc5c8d0..5c794445882 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -224,6 +224,7 @@ module API
mount ::API::NpmInstancePackages
mount ::API::GenericPackages
mount ::API::GoProxy
+ mount ::API::HelmPackages
mount ::API::Pages
mount ::API::PagesDomains
mount ::API::ProjectClusters
diff --git a/lib/api/helm_packages.rb b/lib/api/helm_packages.rb
new file mode 100644
index 00000000000..446dcaf1e3a
--- /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)
+
+ present_carrierwave_file!(package_file.file)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/usage_data_counters/counter_events/package_events.yml b/lib/gitlab/usage_data_counters/counter_events/package_events.yml
index dd66a40a48f..c72f487a442 100644
--- a/lib/gitlab/usage_data_counters/counter_events/package_events.yml
+++ b/lib/gitlab/usage_data_counters/counter_events/package_events.yml
@@ -21,6 +21,7 @@
- i_package_golang_delete_package
- i_package_golang_pull_package
- i_package_golang_push_package
+- i_package_helm_pull_package
- i_package_maven_delete_package
- i_package_maven_pull_package
- i_package_maven_push_package
diff --git a/lib/gitlab/usage_data_counters/known_events/package_events.yml b/lib/gitlab/usage_data_counters/known_events/package_events.yml
index d8ad2b538d6..e5031599dd0 100644
--- a/lib/gitlab/usage_data_counters/known_events/package_events.yml
+++ b/lib/gitlab/usage_data_counters/known_events/package_events.yml
@@ -47,6 +47,14 @@
category: user_packages
aggregation: weekly
redis_slot: package
+- name: i_package_helm_deploy_token
+ category: deploy_token_packages
+ aggregation: weekly
+ redis_slot: package
+- name: i_package_helm_user
+ category: user_packages
+ aggregation: weekly
+ redis_slot: package
- name: i_package_maven_deploy_token
category: deploy_token_packages
aggregation: weekly