فهرست منبع

Merge pull request #30272 from AkihiroSuda/fix-cli-json

Fix broken JSON support in cli/command/formatter
Vincent Demeester 8 سال پیش
والد
کامیت
baecb6f499
3فایلهای تغییر یافته به همراه20 افزوده شده و 0 حذف شده
  1. 12 0
      cli/command/formatter/disk_usage.go
  2. 4 0
      cli/command/formatter/image.go
  3. 4 0
      cli/command/formatter/stats.go

+ 12 - 0
cli/command/formatter/disk_usage.go

@@ -158,6 +158,10 @@ type diskUsageImagesContext struct {
 	images    []*types.ImageSummary
 }
 
+func (c *diskUsageImagesContext) MarshalJSON() ([]byte, error) {
+	return marshalJSON(c)
+}
+
 func (c *diskUsageImagesContext) Type() string {
 	c.AddHeader(typeHeader)
 	return "Images"
@@ -209,6 +213,10 @@ type diskUsageContainersContext struct {
 	containers []*types.Container
 }
 
+func (c *diskUsageContainersContext) MarshalJSON() ([]byte, error) {
+	return marshalJSON(c)
+}
+
 func (c *diskUsageContainersContext) Type() string {
 	c.AddHeader(typeHeader)
 	return "Containers"
@@ -273,6 +281,10 @@ type diskUsageVolumesContext struct {
 	volumes []*types.Volume
 }
 
+func (c *diskUsageVolumesContext) MarshalJSON() ([]byte, error) {
+	return marshalJSON(c)
+}
+
 func (c *diskUsageVolumesContext) Type() string {
 	c.AddHeader(typeHeader)
 	return "Local Volumes"

+ 4 - 0
cli/command/formatter/image.go

@@ -190,6 +190,10 @@ type imageContext struct {
 	digest string
 }
 
+func (c *imageContext) MarshalJSON() ([]byte, error) {
+	return marshalJSON(c)
+}
+
 func (c *imageContext) ID() string {
 	c.AddHeader(imageIDHeader)
 	if c.trunc {

+ 4 - 0
cli/command/formatter/stats.go

@@ -138,6 +138,10 @@ type containerStatsContext struct {
 	s StatsEntry
 }
 
+func (c *containerStatsContext) MarshalJSON() ([]byte, error) {
+	return marshalJSON(c)
+}
+
 func (c *containerStatsContext) Container() string {
 	c.AddHeader(containerHeader)
 	return c.s.Container