mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
'docker inspect' supports pinned versions again (eg. 'docker inspect PATH:revision')
This commit is contained in:
parent
89245360e8
commit
f5f26a510f
2 changed files with 18 additions and 3 deletions
|
@ -308,8 +308,10 @@ func (srv *Server) CmdInspect(stdin io.ReadCloser, stdout io.Writer, args ...str
|
||||||
var obj interface{}
|
var obj interface{}
|
||||||
if container := srv.containers.Get(name); container != nil {
|
if container := srv.containers.Get(name); container != nil {
|
||||||
obj = container
|
obj = container
|
||||||
//} else if image, err := srv.images.List(name); image != nil {
|
} else if image, err := srv.images.Find(name); err != nil {
|
||||||
// obj = image
|
return err
|
||||||
|
} else if image != nil {
|
||||||
|
obj = image
|
||||||
} else {
|
} else {
|
||||||
return errors.New("No such container or image: " + name)
|
return errors.New("No such container or image: " + name)
|
||||||
}
|
}
|
||||||
|
|
15
fs/store.go
15
fs/store.go
|
@ -12,6 +12,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -128,7 +129,19 @@ func (store *Store) Find(pth string) (*Image, error) {
|
||||||
return img, nil
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if len(images) < 1 {
|
} else if len(images) < 1 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue