mirror of https://github.com/docker/cli.git
Fix broken JSON support in cli/command/formatter
How to test (it should not print `{}`, and just returns JSON with the actual data): $ docker images --format '{{json .}}' $ docker container stats --format '{{json .}}' Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
parent
e4a2c958e3
commit
775d9759c6
|
@ -158,6 +158,10 @@ type diskUsageImagesContext struct {
|
||||||
images []*types.ImageSummary
|
images []*types.ImageSummary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *diskUsageImagesContext) MarshalJSON() ([]byte, error) {
|
||||||
|
return marshalJSON(c)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *diskUsageImagesContext) Type() string {
|
func (c *diskUsageImagesContext) Type() string {
|
||||||
c.AddHeader(typeHeader)
|
c.AddHeader(typeHeader)
|
||||||
return "Images"
|
return "Images"
|
||||||
|
@ -209,6 +213,10 @@ type diskUsageContainersContext struct {
|
||||||
containers []*types.Container
|
containers []*types.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *diskUsageContainersContext) MarshalJSON() ([]byte, error) {
|
||||||
|
return marshalJSON(c)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *diskUsageContainersContext) Type() string {
|
func (c *diskUsageContainersContext) Type() string {
|
||||||
c.AddHeader(typeHeader)
|
c.AddHeader(typeHeader)
|
||||||
return "Containers"
|
return "Containers"
|
||||||
|
@ -273,6 +281,10 @@ type diskUsageVolumesContext struct {
|
||||||
volumes []*types.Volume
|
volumes []*types.Volume
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *diskUsageVolumesContext) MarshalJSON() ([]byte, error) {
|
||||||
|
return marshalJSON(c)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *diskUsageVolumesContext) Type() string {
|
func (c *diskUsageVolumesContext) Type() string {
|
||||||
c.AddHeader(typeHeader)
|
c.AddHeader(typeHeader)
|
||||||
return "Local Volumes"
|
return "Local Volumes"
|
||||||
|
|
|
@ -190,6 +190,10 @@ type imageContext struct {
|
||||||
digest string
|
digest string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *imageContext) MarshalJSON() ([]byte, error) {
|
||||||
|
return marshalJSON(c)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *imageContext) ID() string {
|
func (c *imageContext) ID() string {
|
||||||
c.AddHeader(imageIDHeader)
|
c.AddHeader(imageIDHeader)
|
||||||
if c.trunc {
|
if c.trunc {
|
||||||
|
|
|
@ -138,6 +138,10 @@ type containerStatsContext struct {
|
||||||
s StatsEntry
|
s StatsEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *containerStatsContext) MarshalJSON() ([]byte, error) {
|
||||||
|
return marshalJSON(c)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *containerStatsContext) Container() string {
|
func (c *containerStatsContext) Container() string {
|
||||||
c.AddHeader(containerHeader)
|
c.AddHeader(containerHeader)
|
||||||
return c.s.Container
|
return c.s.Container
|
||||||
|
|
Loading…
Reference in New Issue