Modify repository name regex to match index
This commit is contained in:
parent
96593dc278
commit
9c366e092d
2 changed files with 13 additions and 3 deletions
|
@ -70,7 +70,7 @@ func validateRepositoryName(repositoryName string) error {
|
||||||
if !validNamespace.MatchString(namespace) {
|
if !validNamespace.MatchString(namespace) {
|
||||||
return fmt.Errorf("Invalid namespace name (%s), only [a-z0-9_] are allowed, size between 4 and 30", namespace)
|
return fmt.Errorf("Invalid namespace name (%s), only [a-z0-9_] are allowed, size between 4 and 30", namespace)
|
||||||
}
|
}
|
||||||
validRepo := regexp.MustCompile(`^([a-zA-Z0-9-_.]+)$`)
|
validRepo := regexp.MustCompile(`^([a-z0-9-_.]+)$`)
|
||||||
if !validRepo.MatchString(name) {
|
if !validRepo.MatchString(name) {
|
||||||
return fmt.Errorf("Invalid repository name (%s), only [a-zA-Z0-9-_.] are allowed", name)
|
return fmt.Errorf("Invalid repository name (%s), only [a-zA-Z0-9-_.] are allowed", name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,11 +159,11 @@ func TestPushRegistryTag(t *testing.T) {
|
||||||
func TestPushImageJSONIndex(t *testing.T) {
|
func TestPushImageJSONIndex(t *testing.T) {
|
||||||
r := spawnTestRegistry(t)
|
r := spawnTestRegistry(t)
|
||||||
imgData := []*ImgData{
|
imgData := []*ImgData{
|
||||||
&ImgData{
|
{
|
||||||
ID: "77dbf71da1d00e3fbddc480176eac8994025630c6590d11cfc8fe1209c2a1d20",
|
ID: "77dbf71da1d00e3fbddc480176eac8994025630c6590d11cfc8fe1209c2a1d20",
|
||||||
Checksum: "sha256:1ac330d56e05eef6d438586545ceff7550d3bdcb6b19961f12c5ba714ee1bb37",
|
Checksum: "sha256:1ac330d56e05eef6d438586545ceff7550d3bdcb6b19961f12c5ba714ee1bb37",
|
||||||
},
|
},
|
||||||
&ImgData{
|
{
|
||||||
ID: "42d718c941f5c532ac049bf0b0ab53f0062f09a03afd4aa4a02c098e46032b9d",
|
ID: "42d718c941f5c532ac049bf0b0ab53f0062f09a03afd4aa4a02c098e46032b9d",
|
||||||
Checksum: "sha256:bea7bf2e4bacd479344b737328db47b18880d09096e6674165533aa994f5e9f2",
|
Checksum: "sha256:bea7bf2e4bacd479344b737328db47b18880d09096e6674165533aa994f5e9f2",
|
||||||
},
|
},
|
||||||
|
@ -196,3 +196,13 @@ func TestSearchRepositories(t *testing.T) {
|
||||||
}
|
}
|
||||||
assertEqual(t, results.NumResults, 0, "Expected 0 search results")
|
assertEqual(t, results.NumResults, 0, "Expected 0 search results")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestValidRepositoryName(t *testing.T) {
|
||||||
|
if err := validateRepositoryName("docker/docker"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := validateRepositoryName("docker/Docker"); err == nil {
|
||||||
|
t.Log("Repository name should be invalid")
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue