Skip to content

Commit

Permalink
backport of commit 6469b59 (#24770)
Browse files Browse the repository at this point in the history
Co-authored-by: Vincent Ducamps <[email protected]>
  • Loading branch information
hc-github-team-nomad-core and vincentDcmps authored Jan 3, 2025
1 parent a46578b commit d88e81b
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 d88e81b

Please sign in to comment.