Skip to content

Commit

Permalink
backport of commit 6469b59
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentDcmps authored Jan 3, 2025
1 parent a46578b commit 892a90b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
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

0 comments on commit 892a90b

Please sign in to comment.