2012-11-27 22:14:05 -05:00
|
|
|
module Gitlab
|
|
|
|
module Regex
|
|
|
|
extend self
|
|
|
|
|
2015-03-24 09:55:14 -04:00
|
|
|
def namespace_name_regex
|
2015-02-08 18:01:31 -05:00
|
|
|
@namespace_name_regex ||= /\A[\p{Alnum}\p{Pd}_\. ]*\z/.freeze
|
2014-06-26 03:53:01 -04:00
|
|
|
end
|
|
|
|
|
2015-03-24 09:55:14 -04:00
|
|
|
def namespace_name_regex_message
|
2015-02-08 18:01:31 -05:00
|
|
|
"can contain only letters, digits, '_', '.', dash and space."
|
2015-03-24 09:55:14 -04:00
|
|
|
end
|
|
|
|
|
2012-12-25 17:50:41 -05:00
|
|
|
def project_name_regex
|
2016-11-11 06:27:23 -05:00
|
|
|
@project_name_regex ||= /\A[\p{Alnum}\u{00A9}-\u{1f9c0}_][\p{Alnum}\p{Pd}\u{00A9}-\u{1f9c0}_\. ]*\z/.freeze
|
2012-12-25 17:50:41 -05:00
|
|
|
end
|
|
|
|
|
2015-03-24 09:55:14 -04:00
|
|
|
def project_name_regex_message
|
2016-11-11 06:27:23 -05:00
|
|
|
"can contain only letters, digits, emojis, '_', '.', dash, space. " \
|
|
|
|
"It must start with letter, digit, emoji or '_'."
|
2014-06-26 03:53:01 -04:00
|
|
|
end
|
|
|
|
|
2015-03-24 09:55:14 -04:00
|
|
|
def file_name_regex
|
2017-01-15 03:48:35 -05:00
|
|
|
@file_name_regex ||= /\A[[[:alnum:]]_\-\.\@\+]*\z/.freeze
|
2012-11-27 22:14:05 -05:00
|
|
|
end
|
2014-01-14 12:26:01 -05:00
|
|
|
|
2015-03-24 09:55:14 -04:00
|
|
|
def file_name_regex_message
|
2017-01-15 03:48:35 -05:00
|
|
|
"can contain only letters, digits, '_', '-', '@', '+' and '.'."
|
2014-06-26 03:53:01 -04:00
|
|
|
end
|
|
|
|
|
2016-05-08 16:50:30 -04:00
|
|
|
def container_registry_reference_regex
|
2017-05-24 16:59:26 -04:00
|
|
|
Gitlab::PathRegex.git_reference_regex
|
2016-04-18 08:14:40 -04:00
|
|
|
end
|
2016-06-14 07:04:21 -04:00
|
|
|
|
2017-04-03 05:38:39 -04:00
|
|
|
##
|
|
|
|
# Docker Distribution Registry 2.4.1 repository name rules
|
|
|
|
#
|
|
|
|
def container_repository_name_regex
|
|
|
|
@container_repository_regex ||= %r{\A[a-z0-9]+(?:[-._/][a-z0-9]+)*\Z}
|
|
|
|
end
|
|
|
|
|
2016-06-14 07:04:21 -04:00
|
|
|
def environment_name_regex
|
2016-09-19 03:01:04 -04:00
|
|
|
@environment_name_regex ||= /\A[a-zA-Z0-9_\\\/\${}. -]+\z/.freeze
|
2016-06-14 07:04:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def environment_name_regex_message
|
2016-09-19 03:01:04 -04:00
|
|
|
"can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.' and spaces"
|
2016-06-14 07:04:21 -04:00
|
|
|
end
|
2016-12-08 11:36:26 -05:00
|
|
|
|
|
|
|
def kubernetes_namespace_regex
|
|
|
|
/\A[a-z0-9]([-a-z0-9]*[a-z0-9])?\z/
|
|
|
|
end
|
|
|
|
|
|
|
|
def kubernetes_namespace_regex_message
|
|
|
|
"can contain only letters, digits or '-', and cannot start or end with '-'"
|
|
|
|
end
|
2016-12-07 20:09:18 -05:00
|
|
|
|
|
|
|
def environment_slug_regex
|
|
|
|
@environment_slug_regex ||= /\A[a-z]([a-z0-9-]*[a-z0-9])?\z/.freeze
|
|
|
|
end
|
|
|
|
|
|
|
|
def environment_slug_regex_message
|
|
|
|
"can contain only lowercase letters, digits, and '-'. " \
|
|
|
|
"Must start with a letter, and cannot end with '-'"
|
|
|
|
end
|
2012-11-27 22:14:05 -05:00
|
|
|
end
|
|
|
|
end
|