mirror of https://github.com/docker/docs.git
fix match
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
parent
2cb0395acf
commit
1f5d66d1f1
|
@ -21,8 +21,10 @@ func (image *Image) Match(IDOrName string) bool {
|
|||
return true
|
||||
}
|
||||
for _, repoTag := range image.RepoTags {
|
||||
parts := strings.SplitN(repoTag, ":", 2)
|
||||
if repoTag == IDOrName || parts[0] == IDOrName {
|
||||
if len(strings.SplitN(repoTag, ":", 2)) == 1 {
|
||||
repoTag = repoTag + ":latest"
|
||||
}
|
||||
if repoTag == IDOrName {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestMatch(t *testing.T) {
|
|||
assert.False(t, img.Match("37"))
|
||||
|
||||
assert.True(t, img.Match("name:latest"))
|
||||
assert.True(t, img.Match("name"))
|
||||
assert.False(t, img.Match("name"))
|
||||
assert.False(t, img.Match("nam"))
|
||||
assert.False(t, img.Match("na"))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue