зеркало из https://github.com/microsoft/docker.git
'docker inspect' supports pinned versions again (eg. 'docker inspect PATH:revision')
This commit is contained in:
Родитель
89245360e8
Коммит
f5f26a510f
|
@ -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)
|
||||
}
|
||||
|
|
15
fs/store.go
15
fs/store.go
|
@ -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 {
|
||||
|
|
Загрузка…
Ссылка в новой задаче