fix match

Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
Victor Vieux 2015-05-15 15:58:44 -07:00
parent 2cb0395acf
commit 1f5d66d1f1
2 changed files with 5 additions and 3 deletions

View File

@ -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
}
}

View File

@ -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"))
}