mirror of
https://github.com/docker/compose.git
synced 2025-07-21 20:54:32 +02:00
restore ContainerName in images --json
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
9a5fa05ad6
commit
ea1c26d22a
@ -88,12 +88,35 @@ func runImages(ctx context.Context, dockerCli command.Cli, backend api.Service,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if opts.Format == "json" {
|
if opts.Format == "json" {
|
||||||
// Convert map to slice
|
|
||||||
var imageList []api.ImageSummary
|
type img struct {
|
||||||
for _, img := range images {
|
ID string `json:"ID"`
|
||||||
imageList = append(imageList, img)
|
ContainerName string `json:"ContainerName"`
|
||||||
|
Repository string `json:"Repository"`
|
||||||
|
Tag string `json:"Tag"`
|
||||||
|
Platform string `json:"Platform"`
|
||||||
|
Size int64 `json:"Size"`
|
||||||
|
LastTagTime time.Time `json:"LastTagTime"`
|
||||||
}
|
}
|
||||||
return formatter.Print(imageList, opts.Format, dockerCli.Out(), nil)
|
// Convert map to slice
|
||||||
|
var imageList []img
|
||||||
|
for ctr, i := range images {
|
||||||
|
imageList = append(imageList, img{
|
||||||
|
ContainerName: ctr,
|
||||||
|
ID: i.ID,
|
||||||
|
Repository: i.Repository,
|
||||||
|
Tag: i.Tag,
|
||||||
|
Platform: platforms.Format(i.Platform),
|
||||||
|
Size: i.Size,
|
||||||
|
LastTagTime: i.LastTagTime,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
json, err := formatter.ToJSON(imageList, "", "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = fmt.Fprintln(dockerCli.Out(), json)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return formatter.Print(images, opts.Format, dockerCli.Out(),
|
return formatter.Print(images, opts.Format, dockerCli.Out(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user