The JSONMessage struct contained fields that were previously used to produce the
`/events` response. However, commit 72f1881df102fce9ad31e98045b91c204dd44513
introduced an events.Message type that replaced the use of JSONMessage for
that purpose, and clients no longer use the JSONMessage struct to unmarshal
those responses.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -126,9 +126,6 @@ type JSONMessage struct {
|
| 126 | 126 |
Status string `json:"status,omitempty"` |
| 127 | 127 |
Progress *JSONProgress `json:"progressDetail,omitempty"` |
| 128 | 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 | 129 |
Error *jsonstream.Error `json:"errorDetail,omitempty"` |
| 133 | 130 |
Aux *json.RawMessage `json:"aux,omitempty"` // Aux contains out-of-band data, such as digests for push signing and image id after building. |
| 134 | 131 |
} |
| ... | ... |
@@ -177,17 +174,9 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
|
| 177 | 177 |
} else if jm.Progress != nil && jm.Progress.String() != "" { // disable progressbar in non-terminal
|
| 178 | 178 |
return nil |
| 179 | 179 |
} |
| 180 |
- if jm.TimeNano != 0 {
|
|
| 181 |
- _, _ = fmt.Fprintf(out, "%s ", time.Unix(0, jm.TimeNano).Format(RFC3339NanoFixed)) |
|
| 182 |
- } else if jm.Time != 0 {
|
|
| 183 |
- _, _ = fmt.Fprintf(out, "%s ", time.Unix(jm.Time, 0).Format(RFC3339NanoFixed)) |
|
| 184 |
- } |
|
| 185 | 180 |
if jm.ID != "" {
|
| 186 | 181 |
_, _ = fmt.Fprintf(out, "%s: ", jm.ID) |
| 187 | 182 |
} |
| 188 |
- if jm.From != "" {
|
|
| 189 |
- _, _ = fmt.Fprintf(out, "(from %s) ", jm.From) |
|
| 190 |
- } |
|
| 191 | 183 |
if jm.Progress != nil && isTerminal {
|
| 192 | 184 |
_, _ = fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl) |
| 193 | 185 |
} else if jm.Stream != "" {
|
| ... | ... |
@@ -112,7 +112,6 @@ func TestProgressString(t *testing.T) {
|
| 112 | 112 |
} |
| 113 | 113 |
|
| 114 | 114 |
func TestJSONMessageDisplay(t *testing.T) {
|
| 115 |
- now := time.Now() |
|
| 116 | 115 |
messages := map[JSONMessage][]string{
|
| 117 | 116 |
// Empty |
| 118 | 117 |
{}: {"\n", "\n"},
|
| ... | ... |
@@ -125,34 +124,11 @@ func TestJSONMessageDisplay(t *testing.T) {
|
| 125 | 125 |
}, |
| 126 | 126 |
// General |
| 127 | 127 |
{
|
| 128 |
- Time: now.Unix(), |
|
| 129 | 128 |
ID: "ID", |
| 130 |
- From: "From", |
|
| 131 | 129 |
Status: "status", |
| 132 | 130 |
}: {
|
| 133 |
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(now.Unix(), 0).Format(RFC3339NanoFixed)),
|
|
| 134 |
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(now.Unix(), 0).Format(RFC3339NanoFixed)),
|
|
| 135 |
- }, |
|
| 136 |
- // General, with nano precision time |
|
| 137 |
- {
|
|
| 138 |
- TimeNano: now.UnixNano(), |
|
| 139 |
- ID: "ID", |
|
| 140 |
- From: "From", |
|
| 141 |
- Status: "status", |
|
| 142 |
- }: {
|
|
| 143 |
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(RFC3339NanoFixed)),
|
|
| 144 |
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(RFC3339NanoFixed)),
|
|
| 145 |
- }, |
|
| 146 |
- // General, with both times Nano is preferred |
|
| 147 |
- {
|
|
| 148 |
- Time: now.Unix(), |
|
| 149 |
- TimeNano: now.UnixNano(), |
|
| 150 |
- ID: "ID", |
|
| 151 |
- From: "From", |
|
| 152 |
- Status: "status", |
|
| 153 |
- }: {
|
|
| 154 |
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(RFC3339NanoFixed)),
|
|
| 155 |
- fmt.Sprintf("%v ID: (from From) status\n", time.Unix(0, now.UnixNano()).Format(RFC3339NanoFixed)),
|
|
| 131 |
+ "ID: status\n", |
|
| 132 |
+ "ID: status\n", |
|
| 156 | 133 |
}, |
| 157 | 134 |
// Stream over status |
| 158 | 135 |
{
|
| ... | ... |
@@ -126,9 +126,6 @@ type JSONMessage struct {
|
| 126 | 126 |
Status string `json:"status,omitempty"` |
| 127 | 127 |
Progress *JSONProgress `json:"progressDetail,omitempty"` |
| 128 | 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 | 129 |
Error *jsonstream.Error `json:"errorDetail,omitempty"` |
| 133 | 130 |
Aux *json.RawMessage `json:"aux,omitempty"` // Aux contains out-of-band data, such as digests for push signing and image id after building. |
| 134 | 131 |
} |
| ... | ... |
@@ -177,17 +174,9 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
|
| 177 | 177 |
} else if jm.Progress != nil && jm.Progress.String() != "" { // disable progressbar in non-terminal
|
| 178 | 178 |
return nil |
| 179 | 179 |
} |
| 180 |
- if jm.TimeNano != 0 {
|
|
| 181 |
- _, _ = fmt.Fprintf(out, "%s ", time.Unix(0, jm.TimeNano).Format(RFC3339NanoFixed)) |
|
| 182 |
- } else if jm.Time != 0 {
|
|
| 183 |
- _, _ = fmt.Fprintf(out, "%s ", time.Unix(jm.Time, 0).Format(RFC3339NanoFixed)) |
|
| 184 |
- } |
|
| 185 | 180 |
if jm.ID != "" {
|
| 186 | 181 |
_, _ = fmt.Fprintf(out, "%s: ", jm.ID) |
| 187 | 182 |
} |
| 188 |
- if jm.From != "" {
|
|
| 189 |
- _, _ = fmt.Fprintf(out, "(from %s) ", jm.From) |
|
| 190 |
- } |
|
| 191 | 183 |
if jm.Progress != nil && isTerminal {
|
| 192 | 184 |
_, _ = fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl) |
| 193 | 185 |
} else if jm.Stream != "" {
|