Skip to content

Commit 9839e97

Browse files
author
Shishir Mahajan
committed
Docker Tag command: Relax the restriction on namespace (username) length from 30 to 255 characters.
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
1 parent e2ca237 commit 9839e97

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

registry/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ func validateRemoteName(remoteName string) error {
223223
if !validNamespaceChars.MatchString(namespace) {
224224
return fmt.Errorf("Invalid namespace name (%s). Only [a-z0-9-_] are allowed.", namespace)
225225
}
226-
if len(namespace) < 4 || len(namespace) > 30 {
227-
return fmt.Errorf("Invalid namespace name (%s). Cannot be fewer than 4 or more than 30 characters.", namespace)
226+
if len(namespace) < 2 || len(namespace) > 255 {
227+
return fmt.Errorf("Invalid namespace name (%s). Cannot be fewer than 2 or more than 255 characters.", namespace)
228228
}
229229
if strings.HasPrefix(namespace, "-") || strings.HasSuffix(namespace, "-") {
230230
return fmt.Errorf("Invalid namespace name (%s). Cannot begin or end with a hyphen.", namespace)

registry/registry_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,9 @@ func TestValidRemoteName(t *testing.T) {
751751

752752
// Allow underscores everywhere (as opposed to hyphens).
753753
"____/____",
754+
755+
//Username doc and image name docker being tested.
756+
"doc/docker",
754757
}
755758
for _, repositoryName := range validRepositoryNames {
756759
if err := validateRemoteName(repositoryName); err != nil {
@@ -776,11 +779,14 @@ func TestValidRemoteName(t *testing.T) {
776779
// Disallow consecutive hyphens.
777780
"dock--er/docker",
778781

779-
// Namespace too short.
780-
"doc/docker",
781-
782782
// No repository.
783783
"docker/",
784+
785+
//namespace too short
786+
"d/docker",
787+
788+
//namespace too long
789+
"this_is_not_a_valid_namespace_because_its_lenth_is_greater_than_255_this_is_not_a_valid_namespace_because_its_lenth_is_greater_than_255_this_is_not_a_valid_namespace_because_its_lenth_is_greater_than_255_this_is_not_a_valid_namespace_because_its_lenth_is_greater_than_255/docker",
784790
}
785791
for _, repositoryName := range invalidRepositoryNames {
786792
if err := validateRemoteName(repositoryName); err == nil {

0 commit comments

Comments
 (0)