mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-22 08:38:03 +01:00
Merge pull request #1325 from ywk253100/170207_multinamespace
Support multiple namespaces in repo name
This commit is contained in:
commit
9533c13120
@ -53,7 +53,7 @@ func ParseRepository(repository string) (project, rest string) {
|
||||
rest = repository
|
||||
return
|
||||
}
|
||||
index := strings.LastIndex(repository, "/")
|
||||
index := strings.Index(repository, "/")
|
||||
project = repository[0:index]
|
||||
rest = repository[index+1:]
|
||||
return
|
||||
|
@ -65,10 +65,10 @@ func TestParseRepository(t *testing.T) {
|
||||
|
||||
repository = "library/test/ubuntu"
|
||||
project, rest = ParseRepository(repository)
|
||||
if project != "library/test" {
|
||||
if project != "library" {
|
||||
t.Errorf("unexpected project: %s != %s", project, "library/test")
|
||||
}
|
||||
if rest != "ubuntu" {
|
||||
if rest != "test/ubuntu" {
|
||||
t.Errorf("unexpected rest: %s != %s", rest, "ubuntu")
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ func TriggerReplication(policyID int64, repository string,
|
||||
func GetPoliciesByRepository(repository string) ([]*models.RepPolicy, error) {
|
||||
repository = strings.TrimSpace(repository)
|
||||
repository = strings.TrimRight(repository, "/")
|
||||
projectName := repository[:strings.LastIndex(repository, "/")]
|
||||
projectName, _ := utils.ParseRepository(repository)
|
||||
|
||||
project, err := dao.GetProjectByName(projectName)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user