summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-11-16 09:35:27 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2017-11-16 09:35:27 +0000
commite07b0bd2954d1c95499d3303289bef0a17296667 (patch)
treed99266024e674c1a00d4b792fd0b0a2d46a58953
parent3ba84d4ba5953f5cf603fbf7e0e2d2bcf03f93eb (diff)
parent3e3c84a78117b22357e7bb06b91c976259746917 (diff)
downloadgitlab-ce-e07b0bd2954d1c95499d3303289bef0a17296667.tar.gz
Merge branch 'fix/gb/update-registry-path-reference-regexp' into 'master'
Update container repository path reference Closes #40199 See merge request gitlab-org/gitlab-ce!15417
-rw-r--r--changelogs/unreleased/fix-gb-update-registry-path-reference-regexp.yml5
-rw-r--r--lib/gitlab/regex.rb2
-rw-r--r--spec/lib/container_registry/path_spec.rb18
3 files changed, 24 insertions, 1 deletions
diff --git a/changelogs/unreleased/fix-gb-update-registry-path-reference-regexp.yml b/changelogs/unreleased/fix-gb-update-registry-path-reference-regexp.yml
new file mode 100644
index 00000000000..55c1089ade5
--- /dev/null
+++ b/changelogs/unreleased/fix-gb-update-registry-path-reference-regexp.yml
@@ -0,0 +1,5 @@
+---
+title: Update container repository path reference and allow using double underscore
+merge_request: 15417
+author:
+type: fixed
diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb
index bd677ec4bf3..2c7b8af83f2 100644
--- a/lib/gitlab/regex.rb
+++ b/lib/gitlab/regex.rb
@@ -25,7 +25,7 @@ module Gitlab
# See https://github.com/docker/distribution/blob/master/reference/regexp.go.
#
def container_repository_name_regex
- @container_repository_regex ||= %r{\A[a-z0-9]+(?:[-._/][a-z0-9]+)*\Z}
+ @container_repository_regex ||= %r{\A[a-z0-9]+((?:[._/]|__|[-])[a-z0-9]+)*\Z}
end
##
diff --git a/spec/lib/container_registry/path_spec.rb b/spec/lib/container_registry/path_spec.rb
index 84cacdd3f0d..010deae822c 100644
--- a/spec/lib/container_registry/path_spec.rb
+++ b/spec/lib/container_registry/path_spec.rb
@@ -86,6 +86,24 @@ describe ContainerRegistry::Path do
it { is_expected.to be_valid }
end
+
+ context 'when path contains double underscore' do
+ let(:path) { 'my/repository__name' }
+
+ it { is_expected.to be_valid }
+ end
+
+ context 'when path contains invalid separator with dot' do
+ let(:path) { 'some/registry-.name' }
+
+ it { is_expected.not_to be_valid }
+ end
+
+ context 'when path contains invalid separator with underscore' do
+ let(:path) { 'some/registry._name' }
+
+ it { is_expected.not_to be_valid }
+ end
end
describe '#has_repository?' do