Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
23603d56
Commit
23603d56
authored
Mar 16, 2021
by
Mathieu Parent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helm regexps
Item 1.1 of
https://gitlab.com/gitlab-org/gitlab/-/issues/18997#note_530270349
parent
c4aae485
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
lib/gitlab/regex.rb
lib/gitlab/regex.rb
+12
-0
spec/lib/gitlab/regex_spec.rb
spec/lib/gitlab/regex_spec.rb
+44
-0
No files found.
lib/gitlab/regex.rb
View file @
23603d56
...
@@ -125,6 +125,18 @@ module Gitlab
...
@@ -125,6 +125,18 @@ module Gitlab
@debian_component_regex
||=
%r{
#{
debian_distribution_regex
}
}
.
freeze
@debian_component_regex
||=
%r{
#{
debian_distribution_regex
}
}
.
freeze
end
end
def
helm_channel_regex
@helm_channel_regex
||=
%r{
\A
[-
\.\_
a-zA-Z0-9]+
\z
}
.
freeze
end
def
helm_package_regex
@helm_package_regex
||=
%r{
#{
helm_channel_regex
}
}
.
freeze
end
def
helm_version_regex
@helm_version_regex
||=
%r{
#{
prefixed_semver_regex
}
}
.
freeze
end
def
unbounded_semver_regex
def
unbounded_semver_regex
# See the official regex: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
# See the official regex: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
...
...
spec/lib/gitlab/regex_spec.rb
View file @
23603d56
...
@@ -628,6 +628,50 @@ RSpec.describe Gitlab::Regex do
...
@@ -628,6 +628,50 @@ RSpec.describe Gitlab::Regex do
it
{
is_expected
.
not_to
match
(
'hé'
)
}
it
{
is_expected
.
not_to
match
(
'hé'
)
}
end
end
describe
'.helm_channel_regex'
do
subject
{
described_class
.
helm_channel_regex
}
it
{
is_expected
.
to
match
(
'release'
)
}
it
{
is_expected
.
to
match
(
'my-repo'
)
}
it
{
is_expected
.
to
match
(
'my-repo42'
)
}
# Do not allow empty
it
{
is_expected
.
not_to
match
(
''
)
}
# Do not allow Unicode
it
{
is_expected
.
not_to
match
(
'hé'
)
}
end
describe
'.helm_package_regex'
do
subject
{
described_class
.
helm_package_regex
}
it
{
is_expected
.
to
match
(
'release'
)
}
it
{
is_expected
.
to
match
(
'my-repo'
)
}
it
{
is_expected
.
to
match
(
'my-repo42'
)
}
# Do not allow empty
it
{
is_expected
.
not_to
match
(
''
)
}
# Do not allow Unicode
it
{
is_expected
.
not_to
match
(
'hé'
)
}
it
{
is_expected
.
not_to
match
(
'my/../repo'
)
}
it
{
is_expected
.
not_to
match
(
'me%2f%2e%2e%2f'
)
}
end
describe
'.helm_version_regex'
do
subject
{
described_class
.
helm_version_regex
}
it
{
is_expected
.
to
match
(
'v1.2.3'
)
}
it
{
is_expected
.
to
match
(
'v1.2.3-beta'
)
}
it
{
is_expected
.
to
match
(
'v1.2.3-alpha.3'
)
}
it
{
is_expected
.
not_to
match
(
'v1'
)
}
it
{
is_expected
.
not_to
match
(
'v1.2'
)
}
it
{
is_expected
.
not_to
match
(
'v1./2.3'
)
}
it
{
is_expected
.
not_to
match
(
'v../../../../../1.2.3'
)
}
it
{
is_expected
.
not_to
match
(
'v%2e%2e%2f1.2.3'
)
}
end
describe
'.semver_regex'
do
describe
'.semver_regex'
do
subject
{
described_class
.
semver_regex
}
subject
{
described_class
.
semver_regex
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment