'docker inspect' supports pinned versions again (eg. 'docker inspect PATH:revision')

This commit is contained in:
Solomon Hykes 2013-03-13 13:23:59 -07:00
Родитель 89245360e8
Коммит f5f26a510f
2 изменённых файлов: 18 добавлений и 3 удалений

Просмотреть файл

@ -308,8 +308,10 @@ func (srv *Server) CmdInspect(stdin io.ReadCloser, stdout io.Writer, args ...str
var obj interface{}
if container := srv.containers.Get(name); container != nil {
obj = container
//} else if image, err := srv.images.List(name); image != nil {
// obj = image
} else if image, err := srv.images.Find(name); err != nil {
return err
} else if image != nil {
obj = image
} else {
return errors.New("No such container or image: " + name)
}

Просмотреть файл

@ -12,6 +12,7 @@ import (
"os"
"path"
"path/filepath"
"strings"
"syscall"
"time"
)
@ -128,7 +129,19 @@ func (store *Store) Find(pth string) (*Image, error) {
return img, nil
}
images, err := store.orm.Select(Image{}, "select images.* from images, paths where Path=? and paths.Image=images.Id order by images.Created desc limit 1", pth)
var q string
var args []interface{}
// FIXME: this breaks if the path contains a ':'
// If format is path:rev
if parts := strings.SplitN(pth, ":", 2); len(parts) == 2 {
q = "select Images.* from images, paths where Path=? and images.Id=? and paths.Image=images.Id"
args = []interface{}{parts[0], parts[1]}
// If format is path:rev
} else {
q = "select images.* from images, paths where Path=? and paths.Image=images.Id order by images.Created desc limit 1"
args = []interface{}{parts[0]}
}
images, err := store.orm.Select(Image{}, q, args...)
if err != nil {
return nil, err
} else if len(images) < 1 {