Merge pull request #1325 from ywk253100/170207_multinamespace

Support multiple namespaces in repo name
This commit is contained in:
Daniel Jiang 2017-02-08 13:42:55 +08:00 committed by GitHub
commit 9533c13120
3 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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")
}

View File

@ -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 {