Skip to content

Commit

Permalink
fix(repository): Separate tag in a right way
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanilves committed May 20, 2018
1 parent 684771b commit 4330a06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func ParseRef(ref string) (*Repository, error) {
filterRE = regexp.MustCompile(".*")
case refWithSingleTag:
refParts := strings.Split(fullRef, ":")
fullRepo = strings.TrimRight(fullRef, ":"+refParts[len(refParts)-1])
fullRepo = strings.Replace(fullRef, ":"+refParts[len(refParts)-1], "", 1)
repoTags = []string{refParts[len(refParts)-1]}
isSingle = true
case refWithManyTags:
Expand Down
23 changes: 12 additions & 11 deletions repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ func TestParseRef(t *testing.T) {
}

var testCases = map[string]expectation{
"alpine": {"registry.hub.docker.com", true, "registry.hub.docker.com/alpine", "alpine", "library/alpine", []string{}, ".*", "https://", false, true},
"alp@ne": {"", true, "", "", "", []string{}, "", "", false, false},
"localhost/bitcoin/robot": {"localhost", false, "localhost/bitcoin/robot", "localhost/bitcoin/robot", "bitcoin/robot", []string{}, ".*", "http://", false, true},
"localhost:5000/nada/mindundi": {"localhost:5000", false, "localhost:5000/nada/mindundi", "localhost:5000/nada/mindundi", "nada/mindundi", []string{}, ".*", "http://", false, true},
"localhost:7eff/nada/mindundi": {"", true, "", "", "", []string{}, "", "", false, false},
"quay.io/coreos/awscli:master": {"quay.io", false, "quay.io/coreos/awscli", "quay.io/coreos/awscli", "coreos/awscli", []string{"master"}, "", "https://", true, true},
"registry.org/some/repo=latest,stable": {"registry.org", false, "registry.org/some/repo", "registry.org/some/repo", "some/repo", []string{"latest", "stable"}, "", "https://", false, true},
"registry.org/some/repo=lat!st,stable": {"", true, "", "", "", []string{}, "", "", false, false},
"registry.org/some/repo~/^v1/": {"registry.org", false, "registry.org/some/repo", "registry.org/some/repo", "some/repo", []string{}, "^v1", "https://", false, true},
"registry.org/some/repo~|^v1|": {"", true, "", "", "", []string{}, "", "", false, false},
"ivanilves/lstags": {"registry.hub.docker.com", true, "registry.hub.docker.com/ivanilves/lstags", "ivanilves/lstags", "ivanilves/lstags", []string{}, ".*", "https://", false, true},
"alpine": {"registry.hub.docker.com", true, "registry.hub.docker.com/alpine", "alpine", "library/alpine", []string{}, ".*", "https://", false, true},
"alp@ne": {"", true, "", "", "", []string{}, "", "", false, false},
"localhost/bitcoin/robot": {"localhost", false, "localhost/bitcoin/robot", "localhost/bitcoin/robot", "bitcoin/robot", []string{}, ".*", "http://", false, true},
"localhost:5000/nada/mindundi": {"localhost:5000", false, "localhost:5000/nada/mindundi", "localhost:5000/nada/mindundi", "nada/mindundi", []string{}, ".*", "http://", false, true},
"localhost:7eff/nada/mindundi": {"", true, "", "", "", []string{}, "", "", false, false},
"quay.io/coreos/awscli:master": {"quay.io", false, "quay.io/coreos/awscli", "quay.io/coreos/awscli", "coreos/awscli", []string{"master"}, "", "https://", true, true},
"registry.org/some/repo=latest,stable": {"registry.org", false, "registry.org/some/repo", "registry.org/some/repo", "some/repo", []string{"latest", "stable"}, "", "https://", false, true},
"registry.org/some/repo=lat!st,stable": {"", true, "", "", "", []string{}, "", "", false, false},
"registry.org/some/repo~/^v1/": {"registry.org", false, "registry.org/some/repo", "registry.org/some/repo", "some/repo", []string{}, "^v1", "https://", false, true},
"registry.org/some/repo~|^v1|": {"", true, "", "", "", []string{}, "", "", false, false},
"ivanilves/lstags": {"registry.hub.docker.com", true, "registry.hub.docker.com/ivanilves/lstags", "ivanilves/lstags", "ivanilves/lstags", []string{}, ".*", "https://", false, true},
"quay.io/coreos/flannel:v0.6.1-ppc64le": {"quay.io", false, "quay.io/coreos/flannel", "quay.io/coreos/flannel", "coreos/flannel", []string{"v0.6.1-ppc64le"}, "", "https://", true, true},
}

assert := assert.New(t)
Expand Down

0 comments on commit 4330a06

Please sign in to comment.