mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
docker: Fix a bug where images with port number and no tags weren't parsed correctly
This commit is contained in:
3
.changelog/24547.txt
Normal file
3
.changelog/24547.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
docker: Fix a bug where images with port number and no tags weren't parsed correctly
|
||||
```
|
||||
@@ -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"},
|
||||
|
||||
@@ -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 != "" {
|
||||
|
||||
Reference in New Issue
Block a user