소스 검색

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

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

Starting with fcee6056dc50de7698772a3049cdfa1eb0f2416f, 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>
Sebastiaan van Stijn 2 년 전
부모
커밋
4cadee65b3
2개의 변경된 파일1개의 추가작업 그리고 4개의 파일을 삭제
  1. 0 3
      pkg/jsonmessage/jsonmessage.go
  2. 1 1
      pkg/jsonmessage/jsonmessage_test.go

+ 0 - 3
pkg/jsonmessage/jsonmessage.go

@@ -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

+ 1 - 1
pkg/jsonmessage/jsonmessage_test.go

@@ -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) {