Browse code

pkg/jsonmessage: stop printing deprecated progressDetail, errorDetail

The API still returns it for backward-compatibility (but probably
shouldn't), but we should no longer print it. This removes the
use of these fields for printing, but keeps them for streamformatter
to use.

- ErrorMessage was deprecated in 3043c2641990d94298c6377b7ef14709263a4709
- ProgressMessage was deprecated in 597e0e69b4c8521f39691d0a07d1f31b7116a337

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/01/13 21:35:42
Showing 5 changed files
... ...
@@ -2647,26 +2647,10 @@ definitions:
2647 2647
         type: "string"
2648 2648
       stream:
2649 2649
         type: "string"
2650
-      error:
2651
-        type: "string"
2652
-        x-nullable: true
2653
-        description: |-
2654
-          errors encountered during the operation.
2655
-
2656
-
2657
-          > **Deprecated**: This field is deprecated since API v1.4, and will be omitted in a future API version. Use the information in errorDetail instead.
2658 2650
       errorDetail:
2659 2651
         $ref: "#/definitions/ErrorDetail"
2660 2652
       status:
2661 2653
         type: "string"
2662
-      progress:
2663
-        type: "string"
2664
-        x-nullable: true
2665
-        description: |-
2666
-          Progress is a pre-formatted presentation of progressDetail.
2667
-
2668
-
2669
-          > **Deprecated**: This field is deprecated since API v1.8, and will be omitted in a future API version. Use the information in progressDetail instead.
2670 2654
       progressDetail:
2671 2655
         $ref: "#/definitions/ProgressDetail"
2672 2656
       aux:
... ...
@@ -2764,52 +2748,20 @@ definitions:
2764 2764
     properties:
2765 2765
       id:
2766 2766
         type: "string"
2767
-      error:
2768
-        type: "string"
2769
-        x-nullable: true
2770
-        description: |-
2771
-          errors encountered during the operation.
2772
-
2773
-
2774
-          > **Deprecated**: This field is deprecated since API v1.4, and will be omitted in a future API version. Use the information in errorDetail instead.
2775 2767
       errorDetail:
2776 2768
         $ref: "#/definitions/ErrorDetail"
2777 2769
       status:
2778 2770
         type: "string"
2779
-      progress:
2780
-        type: "string"
2781
-        x-nullable: true
2782
-        description: |-
2783
-          Progress is a pre-formatted presentation of progressDetail.
2784
-
2785
-
2786
-          > **Deprecated**: This field is deprecated since API v1.8, and will be omitted in a future API version. Use the information in progressDetail instead.
2787 2771
       progressDetail:
2788 2772
         $ref: "#/definitions/ProgressDetail"
2789 2773
 
2790 2774
   PushImageInfo:
2791 2775
     type: "object"
2792 2776
     properties:
2793
-      error:
2794
-        type: "string"
2795
-        x-nullable: true
2796
-        description: |-
2797
-          errors encountered during the operation.
2798
-
2799
-
2800
-          > **Deprecated**: This field is deprecated since API v1.4, and will be omitted in a future API version. Use the information in errorDetail instead.
2801 2777
       errorDetail:
2802 2778
         $ref: "#/definitions/ErrorDetail"
2803 2779
       status:
2804 2780
         type: "string"
2805
-      progress:
2806
-        type: "string"
2807
-        x-nullable: true
2808
-        description: |-
2809
-          Progress is a pre-formatted presentation of progressDetail.
2810
-
2811
-
2812
-          > **Deprecated**: This field is deprecated since API v1.8, and will be omitted in a future API version. Use the information in progressDetail instead.
2813 2781
       progressDetail:
2814 2782
         $ref: "#/definitions/ProgressDetail"
2815 2783
 
... ...
@@ -122,26 +122,15 @@ func (p *JSONProgress) width() int {
122 122
 // the created time, where it from, status, ID of the
123 123
 // message. It's used for docker events.
124 124
 type JSONMessage struct {
125
-	Stream   string        `json:"stream,omitempty"`
126
-	Status   string        `json:"status,omitempty"`
127
-	Progress *JSONProgress `json:"progressDetail,omitempty"`
128
-
129
-	// ProgressMessage is a pre-formatted presentation of [Progress].
130
-	//
131
-	// Deprecated: this field is deprecated since docker v0.7.1 / API v1.8. Use the information in [Progress] instead. This field will be omitted in a future release.
132
-	ProgressMessage string            `json:"progress,omitempty"`
133
-	ID              string            `json:"id,omitempty"`
134
-	From            string            `json:"from,omitempty"`
135
-	Time            int64             `json:"time,omitempty"`
136
-	TimeNano        int64             `json:"timeNano,omitempty"`
137
-	Error           *jsonstream.Error `json:"errorDetail,omitempty"`
138
-
139
-	// ErrorMessage contains errors encountered during the operation.
140
-	//
141
-	// Deprecated: this field is deprecated since docker v0.6.0 / API v1.4. Use [Error.Message] instead. This field will be omitted in a future release.
142
-	ErrorMessage string `json:"error,omitempty"` // deprecated
143
-	// Aux contains out-of-band data, such as digests for push signing and image id after building.
144
-	Aux *json.RawMessage `json:"aux,omitempty"`
125
+	Stream   string            `json:"stream,omitempty"`
126
+	Status   string            `json:"status,omitempty"`
127
+	Progress *JSONProgress     `json:"progressDetail,omitempty"`
128
+	ID       string            `json:"id,omitempty"`
129
+	From     string            `json:"from,omitempty"`
130
+	Time     int64             `json:"time,omitempty"`
131
+	TimeNano int64             `json:"timeNano,omitempty"`
132
+	Error    *jsonstream.Error `json:"errorDetail,omitempty"`
133
+	Aux      *json.RawMessage  `json:"aux,omitempty"` // Aux contains out-of-band data, such as digests for push signing and image id after building.
145 134
 }
146 135
 
147 136
 // We can probably use [aec.EmptyBuilder] for managing the output, but
... ...
@@ -201,8 +190,6 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
201 201
 	}
202 202
 	if jm.Progress != nil && isTerminal {
203 203
 		_, _ = fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl)
204
-	} else if jm.ProgressMessage != "" { // deprecated
205
-		_, _ = fmt.Fprintf(out, "%s %s%s", jm.Status, jm.ProgressMessage, endl)
206 204
 	} else if jm.Stream != "" {
207 205
 		_, _ = fmt.Fprintf(out, "%s%s", jm.Stream, endl)
208 206
 	} else {
... ...
@@ -253,7 +240,7 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr,
253 253
 		if jm.Progress != nil {
254 254
 			jm.Progress.terminalFd = terminalFd
255 255
 		}
256
-		if jm.ID != "" && (jm.Progress != nil || jm.ProgressMessage != "") {
256
+		if jm.ID != "" && jm.Progress != nil {
257 257
 			line, ok := ids[jm.ID]
258 258
 			if !ok {
259 259
 				// NOTE: This approach of using len(id) to
... ...
@@ -162,14 +162,6 @@ func TestJSONMessageDisplay(t *testing.T) {
162 162
 			"stream",
163 163
 			"stream",
164 164
 		},
165
-		// With progress message
166
-		{
167
-			Status:          "status",
168
-			ProgressMessage: "progressMessage",
169
-		}: {
170
-			"status progressMessage",
171
-			"status progressMessage",
172
-		},
173 165
 		// With progress, stream empty
174 166
 		{
175 167
 			Status:   "status",
... ...
@@ -248,11 +240,6 @@ func TestDisplayJSONMessagesStream(t *testing.T) {
248 248
 			"ID: status\n",
249 249
 			"ID: status\n",
250 250
 		},
251
-		// With progress
252
-		`{ "id": "ID", "status": "status", "progress": "ProgressMessage" }`: {
253
-			"ID: status ProgressMessage",
254
-			fmt.Sprintf("\n%c[%dAID: status ProgressMessage%c[%dB", 27, 1, 27, 1),
255
-		},
256 251
 		// With progressDetail
257 252
 		`{ "id": "ID", "status": "status", "progressDetail": { "Current": 1} }`: {
258 253
 			"", // progressbar is disabled in non-terminal
... ...
@@ -2647,26 +2647,10 @@ definitions:
2647 2647
         type: "string"
2648 2648
       stream:
2649 2649
         type: "string"
2650
-      error:
2651
-        type: "string"
2652
-        x-nullable: true
2653
-        description: |-
2654
-          errors encountered during the operation.
2655
-
2656
-
2657
-          > **Deprecated**: This field is deprecated since API v1.4, and will be omitted in a future API version. Use the information in errorDetail instead.
2658 2650
       errorDetail:
2659 2651
         $ref: "#/definitions/ErrorDetail"
2660 2652
       status:
2661 2653
         type: "string"
2662
-      progress:
2663
-        type: "string"
2664
-        x-nullable: true
2665
-        description: |-
2666
-          Progress is a pre-formatted presentation of progressDetail.
2667
-
2668
-
2669
-          > **Deprecated**: This field is deprecated since API v1.8, and will be omitted in a future API version. Use the information in progressDetail instead.
2670 2654
       progressDetail:
2671 2655
         $ref: "#/definitions/ProgressDetail"
2672 2656
       aux:
... ...
@@ -2764,52 +2748,20 @@ definitions:
2764 2764
     properties:
2765 2765
       id:
2766 2766
         type: "string"
2767
-      error:
2768
-        type: "string"
2769
-        x-nullable: true
2770
-        description: |-
2771
-          errors encountered during the operation.
2772
-
2773
-
2774
-          > **Deprecated**: This field is deprecated since API v1.4, and will be omitted in a future API version. Use the information in errorDetail instead.
2775 2767
       errorDetail:
2776 2768
         $ref: "#/definitions/ErrorDetail"
2777 2769
       status:
2778 2770
         type: "string"
2779
-      progress:
2780
-        type: "string"
2781
-        x-nullable: true
2782
-        description: |-
2783
-          Progress is a pre-formatted presentation of progressDetail.
2784
-
2785
-
2786
-          > **Deprecated**: This field is deprecated since API v1.8, and will be omitted in a future API version. Use the information in progressDetail instead.
2787 2771
       progressDetail:
2788 2772
         $ref: "#/definitions/ProgressDetail"
2789 2773
 
2790 2774
   PushImageInfo:
2791 2775
     type: "object"
2792 2776
     properties:
2793
-      error:
2794
-        type: "string"
2795
-        x-nullable: true
2796
-        description: |-
2797
-          errors encountered during the operation.
2798
-
2799
-
2800
-          > **Deprecated**: This field is deprecated since API v1.4, and will be omitted in a future API version. Use the information in errorDetail instead.
2801 2777
       errorDetail:
2802 2778
         $ref: "#/definitions/ErrorDetail"
2803 2779
       status:
2804 2780
         type: "string"
2805
-      progress:
2806
-        type: "string"
2807
-        x-nullable: true
2808
-        description: |-
2809
-          Progress is a pre-formatted presentation of progressDetail.
2810
-
2811
-
2812
-          > **Deprecated**: This field is deprecated since API v1.8, and will be omitted in a future API version. Use the information in progressDetail instead.
2813 2781
       progressDetail:
2814 2782
         $ref: "#/definitions/ProgressDetail"
2815 2783
 
... ...
@@ -122,26 +122,15 @@ func (p *JSONProgress) width() int {
122 122
 // the created time, where it from, status, ID of the
123 123
 // message. It's used for docker events.
124 124
 type JSONMessage struct {
125
-	Stream   string        `json:"stream,omitempty"`
126
-	Status   string        `json:"status,omitempty"`
127
-	Progress *JSONProgress `json:"progressDetail,omitempty"`
128
-
129
-	// ProgressMessage is a pre-formatted presentation of [Progress].
130
-	//
131
-	// Deprecated: this field is deprecated since docker v0.7.1 / API v1.8. Use the information in [Progress] instead. This field will be omitted in a future release.
132
-	ProgressMessage string            `json:"progress,omitempty"`
133
-	ID              string            `json:"id,omitempty"`
134
-	From            string            `json:"from,omitempty"`
135
-	Time            int64             `json:"time,omitempty"`
136
-	TimeNano        int64             `json:"timeNano,omitempty"`
137
-	Error           *jsonstream.Error `json:"errorDetail,omitempty"`
138
-
139
-	// ErrorMessage contains errors encountered during the operation.
140
-	//
141
-	// Deprecated: this field is deprecated since docker v0.6.0 / API v1.4. Use [Error.Message] instead. This field will be omitted in a future release.
142
-	ErrorMessage string `json:"error,omitempty"` // deprecated
143
-	// Aux contains out-of-band data, such as digests for push signing and image id after building.
144
-	Aux *json.RawMessage `json:"aux,omitempty"`
125
+	Stream   string            `json:"stream,omitempty"`
126
+	Status   string            `json:"status,omitempty"`
127
+	Progress *JSONProgress     `json:"progressDetail,omitempty"`
128
+	ID       string            `json:"id,omitempty"`
129
+	From     string            `json:"from,omitempty"`
130
+	Time     int64             `json:"time,omitempty"`
131
+	TimeNano int64             `json:"timeNano,omitempty"`
132
+	Error    *jsonstream.Error `json:"errorDetail,omitempty"`
133
+	Aux      *json.RawMessage  `json:"aux,omitempty"` // Aux contains out-of-band data, such as digests for push signing and image id after building.
145 134
 }
146 135
 
147 136
 // We can probably use [aec.EmptyBuilder] for managing the output, but
... ...
@@ -201,8 +190,6 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
201 201
 	}
202 202
 	if jm.Progress != nil && isTerminal {
203 203
 		_, _ = fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl)
204
-	} else if jm.ProgressMessage != "" { // deprecated
205
-		_, _ = fmt.Fprintf(out, "%s %s%s", jm.Status, jm.ProgressMessage, endl)
206 204
 	} else if jm.Stream != "" {
207 205
 		_, _ = fmt.Fprintf(out, "%s%s", jm.Stream, endl)
208 206
 	} else {
... ...
@@ -253,7 +240,7 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr,
253 253
 		if jm.Progress != nil {
254 254
 			jm.Progress.terminalFd = terminalFd
255 255
 		}
256
-		if jm.ID != "" && (jm.Progress != nil || jm.ProgressMessage != "") {
256
+		if jm.ID != "" && jm.Progress != nil {
257 257
 			line, ok := ids[jm.ID]
258 258
 			if !ok {
259 259
 				// NOTE: This approach of using len(id) to