pkg/jsonmessage: JSONMessage.Display(): remove special case for 401 errors

This special case was added in 3043c26419 as
a sentinel error (`AuthRequiredError`) to check whether authentication
is required (and to prompt the users to authenticate). A later refactor
(946bbee39a) removed the `AuthRequiredError`,
but kept the error-message and logic.

Starting with fcee6056dc, it looks like we
no longer depend on this specific error, so we can return the registry's
error message instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-04-30 23:41:47 +02:00
parent 2adec6c8c0
commit 4cadee65b3
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 1 additions and 4 deletions

View file

@ -168,9 +168,6 @@ func cursorDown(out io.Writer, l uint) {
// entire current line when displaying the progressbar.
func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
if jm.Error != nil {
if jm.Error.Code == 401 {
return fmt.Errorf("authentication is required")
}
return jm.Error
}
var endl string

View file

@ -216,7 +216,7 @@ func TestJSONMessageDisplayWithJSONError(t *testing.T) {
jsonMessage = JSONMessage{Error: &JSONError{401, "Anything"}}
err = jsonMessage.Display(data, true)
assert.Check(t, is.Error(err, "authentication is required"))
assert.Check(t, is.Error(err, "Anything"))
}
func TestDisplayJSONMessagesStreamInvalidJSON(t *testing.T) {