Skip to content

Commit f6d9263

Browse files
dmcgowank8s-infra-cherrypick-robot
authored andcommitted
Register remote errors for clients to access registry errors
Currently the error is not encoded and only the error message can be retrieved on the client. With this change, clients can access the unexpected error type even over grpc. Signed-off-by: Derek McGowan <[email protected]>
1 parent 7c18133 commit f6d9263

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

core/remotes/errors/errors.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,23 @@ import (
2020
"fmt"
2121
"io"
2222
"net/http"
23+
24+
"github.com/containerd/typeurl/v2"
2325
)
2426

2527
var _ error = ErrUnexpectedStatus{}
2628

29+
func init() {
30+
typeurl.Register(&ErrUnexpectedStatus{}, "github.com/containerd/containerd/v2/core/remotes/errors", "ErrUnexpectedStatus")
31+
}
32+
2733
// ErrUnexpectedStatus is returned if a registry API request returned with unexpected HTTP status
2834
type ErrUnexpectedStatus struct {
29-
Status string
30-
StatusCode int
31-
Body []byte
32-
RequestURL, RequestMethod string
35+
Status string `json:"status"`
36+
StatusCode int `json:"statusCode"`
37+
Body []byte `json:"body,omitempty"`
38+
RequestURL string `json:"requestURL,omitempty"`
39+
RequestMethod string `json:"requestMethod,omitempty"`
3340
}
3441

3542
func (e ErrUnexpectedStatus) Error() string {

0 commit comments

Comments
 (0)