2014-09-02 18:07:02 +05:30
|
|
|
module Gitlab
|
|
|
|
module Regex
|
|
|
|
extend self
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
def namespace_name_regex
|
2015-09-11 14:41:01 +05:30
|
|
|
@namespace_name_regex ||= /\A[\p{Alnum}\p{Pd}_\. ]*\z/.freeze
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
def namespace_name_regex_message
|
2015-09-11 14:41:01 +05:30
|
|
|
"can contain only letters, digits, '_', '.', dash and space."
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
def project_name_regex
|
2017-08-17 22:00:37 +05:30
|
|
|
@project_name_regex ||= /\A[\p{Alnum}\u{00A9}-\u{1f9c0}_][\p{Alnum}\p{Pd}\u{00A9}-\u{1f9c0}_\. ]*\z/.freeze
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
def project_name_regex_message
|
2017-08-17 22:00:37 +05:30
|
|
|
"can contain only letters, digits, emojis, '_', '.', dash, space. " \
|
|
|
|
"It must start with letter, digit, emoji or '_'."
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
##
|
2017-09-10 17:25:29 +05:30
|
|
|
# Docker Distribution Registry repository / tag name rules
|
|
|
|
#
|
|
|
|
# See https://github.com/docker/distribution/blob/master/reference/regexp.go.
|
2017-08-17 22:00:37 +05:30
|
|
|
#
|
|
|
|
def container_repository_name_regex
|
2018-03-17 18:26:18 +05:30
|
|
|
@container_repository_regex ||= %r{\A[a-z0-9]+((?:[._/]|__|[-])[a-z0-9]+)*\Z}
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
##
|
|
|
|
# We do not use regexp anchors here because these are not allowed when
|
|
|
|
# used as a routing constraint.
|
|
|
|
#
|
|
|
|
def container_registry_tag_regex
|
|
|
|
@container_registry_tag_regex ||= /[\w][\w.-]{0,127}/
|
|
|
|
end
|
|
|
|
|
|
|
|
def environment_name_regex_chars
|
2018-03-17 18:26:18 +05:30
|
|
|
'a-zA-Z0-9_/\\$\\{\\}\\. \\-'
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
def environment_name_regex
|
2017-09-10 17:25:29 +05:30
|
|
|
@environment_name_regex ||= /\A[#{environment_name_regex_chars}]+\z/.freeze
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def environment_name_regex_message
|
2017-09-10 17:25:29 +05:30
|
|
|
"can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.', and spaces"
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
def kubernetes_namespace_regex
|
|
|
|
/\A[a-z0-9]([-a-z0-9]*[a-z0-9])?\z/
|
|
|
|
end
|
|
|
|
|
|
|
|
def kubernetes_namespace_regex_message
|
2018-03-17 18:26:18 +05:30
|
|
|
"can contain only lowercase letters, digits, and '-'. " \
|
|
|
|
"Must start with a letter, and cannot end with '-'"
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
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
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
def build_trace_section_regex
|
|
|
|
@build_trace_section_regexp ||= /section_((?:start)|(?:end)):(\d+):([a-zA-Z0-9_.-]+)\r\033\[0K/.freeze
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|