Commit f836ae22 authored by Mathieu Parent's avatar Mathieu Parent

Move Debian regexp to ::Packages::Debian

Changelog: changed
parent 8d33f75e
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
module Packages module Packages
module Debian module Debian
DISTRIBUTION_REGEX = %r{[a-z0-9][a-z0-9.-]*}i.freeze
COMPONENT_REGEX = DISTRIBUTION_REGEX.freeze
ARCHITECTURE_REGEX = %r{[a-z0-9][-a-z0-9]*}.freeze
def self.table_name_prefix def self.table_name_prefix
'packages_debian_' 'packages_debian_'
end end
......
...@@ -6,20 +6,17 @@ module API ...@@ -6,20 +6,17 @@ module API
module DebianPackageEndpoints module DebianPackageEndpoints
extend ActiveSupport::Concern extend ActiveSupport::Concern
DISTRIBUTION_REGEX = %r{[a-z0-9][a-z0-9.-]*}i.freeze
COMPONENT_REGEX = %r{[a-z0-9][a-z0-9.-]*}i.freeze
ARCHITECTURE_REGEX = %r{[a-z0-9][-a-z0-9]*}.freeze
LETTER_REGEX = %r{(lib)?[a-z0-9]}.freeze LETTER_REGEX = %r{(lib)?[a-z0-9]}.freeze
PACKAGE_REGEX = API::NO_SLASH_URL_PART_REGEX PACKAGE_REGEX = API::NO_SLASH_URL_PART_REGEX
DISTRIBUTION_REQUIREMENTS = { DISTRIBUTION_REQUIREMENTS = {
distribution: DISTRIBUTION_REGEX distribution: ::Packages::Debian::DISTRIBUTION_REGEX
}.freeze }.freeze
COMPONENT_ARCHITECTURE_REQUIREMENTS = { COMPONENT_ARCHITECTURE_REQUIREMENTS = {
component: COMPONENT_REGEX, component: ::Packages::Debian::COMPONENT_REGEX,
architecture: ARCHITECTURE_REGEX architecture: ::Packages::Debian::ARCHITECTURE_REGEX
}.freeze }.freeze
COMPONENT_LETTER_SOURCE_PACKAGE_REQUIREMENTS = { COMPONENT_LETTER_SOURCE_PACKAGE_REQUIREMENTS = {
component: COMPONENT_REGEX, component: ::Packages::Debian::COMPONENT_REGEX,
letter: LETTER_REGEX, letter: LETTER_REGEX,
source_package: PACKAGE_REGEX source_package: PACKAGE_REGEX
}.freeze }.freeze
......
...@@ -118,15 +118,15 @@ module Gitlab ...@@ -118,15 +118,15 @@ module Gitlab
def debian_architecture_regex def debian_architecture_regex
# See official parser: https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/arch.c?id=9e0c88ec09475f4d1addde9cdba1ad7849720356#n43 # See official parser: https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/arch.c?id=9e0c88ec09475f4d1addde9cdba1ad7849720356#n43
# But we limit to lower case # But we limit to lower case
@debian_architecture_regex ||= %r{\A[a-z0-9][-a-z0-9]*\z}.freeze @debian_architecture_regex ||= %r{\A#{::Packages::Debian::ARCHITECTURE_REGEX}\z}.freeze
end end
def debian_distribution_regex def debian_distribution_regex
@debian_distribution_regex ||= %r{\A[a-z0-9][a-z0-9\.-]*\z}i.freeze @debian_distribution_regex ||= %r{\A#{::Packages::Debian::DISTRIBUTION_REGEX}\z}i.freeze
end end
def debian_component_regex def debian_component_regex
@debian_component_regex ||= %r{#{debian_distribution_regex}}.freeze @debian_component_regex ||= %r{\A#{::Packages::Debian::COMPONENT_REGEX}\z}.freeze
end end
def helm_channel_regex def helm_channel_regex
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment