2020-09-28 09:09:35 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module DebianPackageEndpoints
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
DISTRIBUTION_REGEX = %r{[a-zA-Z0-9][a-zA-Z0-9.-]*}.freeze
|
|
|
|
COMPONENT_REGEX = %r{[a-z-]+}.freeze
|
|
|
|
ARCHITECTURE_REGEX = %r{[a-z][a-z0-9]*}.freeze
|
|
|
|
LETTER_REGEX = %r{(lib)?[a-z0-9]}.freeze
|
|
|
|
PACKAGE_REGEX = API::NO_SLASH_URL_PART_REGEX
|
|
|
|
DISTRIBUTION_REQUIREMENTS = {
|
|
|
|
distribution: DISTRIBUTION_REGEX
|
|
|
|
}.freeze
|
|
|
|
COMPONENT_ARCHITECTURE_REQUIREMENTS = {
|
|
|
|
component: COMPONENT_REGEX,
|
|
|
|
architecture: ARCHITECTURE_REGEX
|
|
|
|
}.freeze
|
|
|
|
COMPONENT_LETTER_SOURCE_PACKAGE_REQUIREMENTS = {
|
|
|
|
component: COMPONENT_REGEX,
|
|
|
|
letter: LETTER_REGEX,
|
|
|
|
source_package: PACKAGE_REGEX
|
|
|
|
}.freeze
|
|
|
|
FILE_NAME_REQUIREMENTS = {
|
|
|
|
file_name: API::NO_SLASH_URL_PART_REGEX
|
|
|
|
}.freeze
|
|
|
|
|
|
|
|
included do
|
2020-10-30 15:08:59 +00:00
|
|
|
feature_category :package_registry
|
|
|
|
|
2020-09-28 09:09:35 +00:00
|
|
|
helpers ::API::Helpers::PackagesHelpers
|
|
|
|
helpers ::API::Helpers::Packages::BasicAuthHelpers
|
|
|
|
|
|
|
|
format :txt
|
2021-01-20 12:11:06 +00:00
|
|
|
content_type :txt, 'text/plain'
|
2020-09-28 09:09:35 +00:00
|
|
|
|
|
|
|
rescue_from ArgumentError do |e|
|
|
|
|
render_api_error!(e.message, 400)
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue_from ActiveRecord::RecordInvalid do |e|
|
|
|
|
render_api_error!(e.message, 400)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
require_packages_enabled!
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
2020-09-30 12:09:53 +00:00
|
|
|
requires :distribution, type: String, desc: 'The Debian Codename', regexp: Gitlab::Regex.debian_distribution_regex
|
2020-09-28 09:09:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
namespace 'dists/*distribution', requirements: DISTRIBUTION_REQUIREMENTS do
|
2021-01-22 12:08:52 +00:00
|
|
|
# GET {projects|groups}/:id/packages/debian/dists/*distribution/Release.gpg
|
2020-09-28 09:09:35 +00:00
|
|
|
desc 'The Release file signature' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.5'
|
|
|
|
end
|
|
|
|
|
2021-02-01 06:09:16 +00:00
|
|
|
route_setting :authentication, deploy_token_allowed: true, basic_auth_personal_access_token: true, job_token_allowed: :basic_auth, authenticate_non_public: true
|
2020-09-28 09:09:35 +00:00
|
|
|
get 'Release.gpg' do
|
|
|
|
not_found!
|
|
|
|
end
|
|
|
|
|
2021-01-22 12:08:52 +00:00
|
|
|
# GET {projects|groups}/:id/packages/debian/dists/*distribution/Release
|
2020-09-28 09:09:35 +00:00
|
|
|
desc 'The unsigned Release file' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.5'
|
|
|
|
end
|
|
|
|
|
2021-02-01 06:09:16 +00:00
|
|
|
route_setting :authentication, deploy_token_allowed: true, basic_auth_personal_access_token: true, job_token_allowed: :basic_auth, authenticate_non_public: true
|
2020-09-28 09:09:35 +00:00
|
|
|
get 'Release' do
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab/-/issues/5835#note_414103286
|
|
|
|
'TODO Release'
|
|
|
|
end
|
|
|
|
|
2021-01-22 12:08:52 +00:00
|
|
|
# GET {projects|groups}/:id/packages/debian/dists/*distribution/InRelease
|
2020-09-28 09:09:35 +00:00
|
|
|
desc 'The signed Release file' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.5'
|
|
|
|
end
|
|
|
|
|
2021-02-01 06:09:16 +00:00
|
|
|
route_setting :authentication, deploy_token_allowed: true, basic_auth_personal_access_token: true, job_token_allowed: :basic_auth, authenticate_non_public: true
|
2020-09-28 09:09:35 +00:00
|
|
|
get 'InRelease' do
|
|
|
|
not_found!
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
2020-09-30 12:09:53 +00:00
|
|
|
requires :component, type: String, desc: 'The Debian Component', regexp: Gitlab::Regex.debian_component_regex
|
|
|
|
requires :architecture, type: String, desc: 'The Debian Architecture', regexp: Gitlab::Regex.debian_architecture_regex
|
2020-09-28 09:09:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
namespace ':component/binary-:architecture', requirements: COMPONENT_ARCHITECTURE_REQUIREMENTS do
|
2021-01-22 12:08:52 +00:00
|
|
|
# GET {projects|groups}/:id/packages/debian/dists/*distribution/:component/binary-:architecture/Packages
|
2020-09-28 09:09:35 +00:00
|
|
|
desc 'The binary files index' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.5'
|
|
|
|
end
|
|
|
|
|
2021-02-01 06:09:16 +00:00
|
|
|
route_setting :authentication, deploy_token_allowed: true, basic_auth_personal_access_token: true, job_token_allowed: :basic_auth, authenticate_non_public: true
|
2020-09-28 09:09:35 +00:00
|
|
|
get 'Packages' do
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab/-/issues/5835#note_414103286
|
|
|
|
'TODO Packages'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
2020-09-30 12:09:53 +00:00
|
|
|
requires :component, type: String, desc: 'The Debian Component', regexp: Gitlab::Regex.debian_component_regex
|
2020-09-28 09:09:35 +00:00
|
|
|
requires :letter, type: String, desc: 'The Debian Classification (first-letter or lib-first-letter)'
|
2020-09-30 12:09:53 +00:00
|
|
|
requires :source_package, type: String, desc: 'The Debian Source Package Name', regexp: Gitlab::Regex.debian_package_name_regex
|
2020-09-28 09:09:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
namespace 'pool/:component/:letter/:source_package', requirements: COMPONENT_LETTER_SOURCE_PACKAGE_REQUIREMENTS do
|
2021-01-22 12:08:52 +00:00
|
|
|
# GET {projects|groups}/:id/packages/debian/pool/:component/:letter/:source_package/:file_name
|
2020-09-28 09:09:35 +00:00
|
|
|
params do
|
|
|
|
requires :file_name, type: String, desc: 'The Debian File Name'
|
|
|
|
end
|
|
|
|
desc 'The package' do
|
|
|
|
detail 'This feature was introduced in GitLab 13.5'
|
|
|
|
end
|
|
|
|
|
2021-02-01 06:09:16 +00:00
|
|
|
route_setting :authentication, deploy_token_allowed: true, basic_auth_personal_access_token: true, job_token_allowed: :basic_auth, authenticate_non_public: true
|
2020-09-28 09:09:35 +00:00
|
|
|
get ':file_name', requirements: FILE_NAME_REQUIREMENTS do
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab/-/issues/5835#note_414103286
|
|
|
|
'TODO File'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|