|
@@ -284,7 +284,7 @@ func (srv *Server) Images(all bool, filter string) ([]APIImages, error) {
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
- outs := []APIImages{} //produce [] when empty instead of 'null'
|
|
|
|
|
|
+ lookup := make(map[string]APIImages)
|
|
for name, repository := range srv.runtime.repositories.Repositories {
|
|
for name, repository := range srv.runtime.repositories.Repositories {
|
|
if filter != "" {
|
|
if filter != "" {
|
|
if match, _ := path.Match(filter, name); !match {
|
|
if match, _ := path.Match(filter, name); !match {
|
|
@@ -292,23 +292,40 @@ func (srv *Server) Images(all bool, filter string) ([]APIImages, error) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for tag, id := range repository {
|
|
for tag, id := range repository {
|
|
- var out APIImages
|
|
|
|
image, err := srv.runtime.graph.Get(id)
|
|
image, err := srv.runtime.graph.Get(id)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Printf("Warning: couldn't load %s from %s/%s: %s", id, name, tag, err)
|
|
log.Printf("Warning: couldn't load %s from %s/%s: %s", id, name, tag, err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- delete(allImages, id)
|
|
|
|
- out.Repository = name
|
|
|
|
- out.Tag = tag
|
|
|
|
- out.ID = image.ID
|
|
|
|
- out.Created = image.Created.Unix()
|
|
|
|
- out.Size = image.Size
|
|
|
|
- out.VirtualSize = image.getParentsSize(0) + image.Size
|
|
|
|
- outs = append(outs, out)
|
|
|
|
|
|
+
|
|
|
|
+ if out, exists := lookup[id]; exists {
|
|
|
|
+ out.RepoTags = append(out.RepoTags, fmt.Sprintf("%s:%s", name, tag))
|
|
|
|
+
|
|
|
|
+ lookup[id] = out
|
|
|
|
+ } else {
|
|
|
|
+ var out APIImages
|
|
|
|
+
|
|
|
|
+ delete(allImages, id)
|
|
|
|
+
|
|
|
|
+ out.ParentId = image.Parent
|
|
|
|
+ out.RepoTags = []string{fmt.Sprintf("%s:%s", name, tag)}
|
|
|
|
+ out.ID = image.ID
|
|
|
|
+ out.Created = image.Created.Unix()
|
|
|
|
+ out.Size = image.Size
|
|
|
|
+ out.VirtualSize = image.getParentsSize(0) + image.Size
|
|
|
|
+
|
|
|
|
+ lookup[id] = out
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // Display images which aren't part of a
|
|
|
|
|
|
+
|
|
|
|
+ outs := make([]APIImages, 0, len(lookup))
|
|
|
|
+ for _, value := range lookup {
|
|
|
|
+ outs = append(outs, value)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Display images which aren't part of a repository/tag
|
|
if filter == "" {
|
|
if filter == "" {
|
|
for _, image := range allImages {
|
|
for _, image := range allImages {
|
|
var out APIImages
|
|
var out APIImages
|