Update container repository path reference

We should allow to use double underscore in the path, and it seems that
our container repository path regexp was outdated.

See https://github.com/docker/distribution/blob/master/reference/regexp.go
This commit is contained in:
Grzegorz Bizon 2017-11-16 09:31:07 +01:00
parent a248bb769f
commit f4df4f9e35
2 changed files with 19 additions and 1 deletions

View file

@ -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
##

View file

@ -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