forked from TrueCloudLab/distribution
Merge pull request #11118 from shishir-a412ed/restriction_username_length
Docker Tag command: Relax the restriction on namespace (username) length from 30 to 255 characters.
This commit is contained in:
commit
606d538448
2 changed files with 11 additions and 5 deletions
|
@ -223,8 +223,8 @@ func validateRemoteName(remoteName string) error {
|
||||||
if !validNamespaceChars.MatchString(namespace) {
|
if !validNamespaceChars.MatchString(namespace) {
|
||||||
return fmt.Errorf("Invalid namespace name (%s). Only [a-z0-9-_] are allowed.", namespace)
|
return fmt.Errorf("Invalid namespace name (%s). Only [a-z0-9-_] are allowed.", namespace)
|
||||||
}
|
}
|
||||||
if len(namespace) < 4 || len(namespace) > 30 {
|
if len(namespace) < 2 || len(namespace) > 255 {
|
||||||
return fmt.Errorf("Invalid namespace name (%s). Cannot be fewer than 4 or more than 30 characters.", namespace)
|
return fmt.Errorf("Invalid namespace name (%s). Cannot be fewer than 2 or more than 255 characters.", namespace)
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(namespace, "-") || strings.HasSuffix(namespace, "-") {
|
if strings.HasPrefix(namespace, "-") || strings.HasSuffix(namespace, "-") {
|
||||||
return fmt.Errorf("Invalid namespace name (%s). Cannot begin or end with a hyphen.", namespace)
|
return fmt.Errorf("Invalid namespace name (%s). Cannot begin or end with a hyphen.", namespace)
|
||||||
|
|
|
@ -751,6 +751,9 @@ func TestValidRemoteName(t *testing.T) {
|
||||||
|
|
||||||
// Allow underscores everywhere (as opposed to hyphens).
|
// Allow underscores everywhere (as opposed to hyphens).
|
||||||
"____/____",
|
"____/____",
|
||||||
|
|
||||||
|
//Username doc and image name docker being tested.
|
||||||
|
"doc/docker",
|
||||||
}
|
}
|
||||||
for _, repositoryName := range validRepositoryNames {
|
for _, repositoryName := range validRepositoryNames {
|
||||||
if err := validateRemoteName(repositoryName); err != nil {
|
if err := validateRemoteName(repositoryName); err != nil {
|
||||||
|
@ -776,11 +779,14 @@ func TestValidRemoteName(t *testing.T) {
|
||||||
// Disallow consecutive hyphens.
|
// Disallow consecutive hyphens.
|
||||||
"dock--er/docker",
|
"dock--er/docker",
|
||||||
|
|
||||||
// Namespace too short.
|
|
||||||
"doc/docker",
|
|
||||||
|
|
||||||
// No repository.
|
// No repository.
|
||||||
"docker/",
|
"docker/",
|
||||||
|
|
||||||
|
//namespace too short
|
||||||
|
"d/docker",
|
||||||
|
|
||||||
|
//namespace too long
|
||||||
|
"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",
|
||||||
}
|
}
|
||||||
for _, repositoryName := range invalidRepositoryNames {
|
for _, repositoryName := range invalidRepositoryNames {
|
||||||
if err := validateRemoteName(repositoryName); err == nil {
|
if err := validateRemoteName(repositoryName); err == nil {
|
||||||
|
|
Loading…
Reference in a new issue