Commit 6c517d23 authored by Nick Thomas's avatar Nick Thomas

Merge branch...

Merge branch '36611-gitlab-container-registry-repository-names-regex-is-not-at-parity-with-docker-registry' into 'master'

Align Container Registry repository names regex with docker distribution

See merge request gitlab-org/gitlab!20318
parents 047a1cfb 745d9517
---
title: Update Container Registry naming restrictions to allow for sequential '-'
merge_request: 20318
author:
type: fixed
......@@ -19,7 +19,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]+((?:[._/]|__|[-]{0,10})[a-z0-9]+)*\Z}
end
##
......
......@@ -61,6 +61,12 @@ describe Gitlab::Regex do
it { is_expected.to match('my/image') }
it { is_expected.to match('my/awesome/image-1') }
it { is_expected.to match('my/awesome/image.test') }
it { is_expected.to match('my/awesome/image--test') }
# docker distribution allows for infinite `-`
# https://github.com/docker/distribution/blob/master/reference/regexp.go#L13
# but we have a range of 0,10 to add a reasonable limit.
it { is_expected.not_to match('my/image-----------test') }
it { is_expected.not_to match('my/image-.test') }
it { is_expected.not_to match('.my/image') }
it { is_expected.not_to match('my/image.') }
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment