Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of docker: Fix a bug where images with port number and no tags weren't parsed correctly into release/1.9.x #24770

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/24547.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
docker: Fix a bug where images with port number and no tags weren't parsed correctly
```
2 changes: 2 additions & 0 deletions drivers/docker/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2860,6 +2860,8 @@ func TestParseDockerImage(t *testing.T) {
Repo string
Tag string
}{
{"host:5000/library/hello-world", "host:5000/library/hello-world", "latest"},
{"host:5000/library/hello-world:1.0", "host:5000/library/hello-world", "1.0"},
{"library/hello-world:1.0", "library/hello-world", "1.0"},
{"library/hello-world", "library/hello-world", "latest"},
{"library/hello-world:latest", "library/hello-world", "latest"},
Expand Down
3 changes: 3 additions & 0 deletions drivers/docker/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func parseDockerImage(image string) (repo, tag string) {
} else if t := repoTag[idx+1:]; !strings.Contains(t, "/") {
repo = repoTag[:idx]
tag = t
} else if t := repoTag[idx+1:]; strings.Contains(t, "/") {
repo = image
tag = "latest"
}

if tag != "" {
Expand Down
Loading