client: Use containerd errdefs to convert http errors

Previously, we were using our own `FromStatusCode` function to map HTTP
status codes to Docker error types. Switch to the containerd code.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-05-19 14:16:41 +02:00
parent a3bee4156f
commit a3ce441ae0
7 changed files with 144 additions and 3 deletions

View File

@@ -5,6 +5,8 @@ import (
)
// FromStatusCode creates an errdef error, based on the provided HTTP status-code
//
// Deprecated: Use [cerrdefs.ToNative] instead
func FromStatusCode(err error, statusCode int) error {
if err == nil {
return nil

View File

@@ -83,6 +83,7 @@ func TestFromStatusCode(t *testing.T) {
for _, tc := range testCases {
t.Run(http.StatusText(tc.status), func(t *testing.T) {
//nolint:staticcheck // ignore SA1019: FromStatusCode is deprecated
err := FromStatusCode(tc.err, tc.status)
if !tc.check(err) {
t.Errorf("unexpected error-type %T", err)