From 3f354e8c1b3675cb7faff87658dc4077d1768d1a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Jan 2025 10:22:38 +0100 Subject: [PATCH 1/2] api/types/registry: use stdlib errors package It was the only use of github.com/pkg/errors inside api/types, which is the package that's imported by external users. Signed-off-by: Sebastiaan van Stijn --- api/types/registry/authconfig.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/types/registry/authconfig.go b/api/types/registry/authconfig.go index 2f49428890..ebd5e4b9e2 100644 --- a/api/types/registry/authconfig.go +++ b/api/types/registry/authconfig.go @@ -3,10 +3,9 @@ import ( "context" "encoding/base64" "encoding/json" + "fmt" "io" "strings" - - "github.com/pkg/errors" ) // AuthHeader is the name of the header used to send encoded registry @@ -98,7 +97,7 @@ func decodeAuthConfigFromReader(rdr io.Reader) (*AuthConfig, error) { } func invalid(err error) error { - return errInvalidParameter{errors.Wrap(err, "invalid X-Registry-Auth header")} + return errInvalidParameter{fmt.Errorf("invalid X-Registry-Auth header: %w", err)} } type errInvalidParameter struct{ error } From 9b5a51a8816b2ad2a278b2fbb56a3a37cb83d0d9 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Jan 2025 10:24:40 +0100 Subject: [PATCH 2/2] api/types/container: remove use of errdefs package in test It was the only use of errdefs inside api/types, which is the package that's imported by external users. Signed-off-by: Sebastiaan van Stijn --- api/types/container/hostconfig_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/api/types/container/hostconfig_test.go b/api/types/container/hostconfig_test.go index 0f6ec277f5..0d24639f2e 100644 --- a/api/types/container/hostconfig_test.go +++ b/api/types/container/hostconfig_test.go @@ -3,7 +3,6 @@ package container import ( "testing" - "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -96,9 +95,19 @@ func TestValidateRestartPolicy(t *testing.T) { if tc.expectedErr == "" { assert.Check(t, err) } else { - assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter)) + assert.Check(t, is.ErrorType(err, isInvalidParameter)) assert.Check(t, is.Error(err, tc.expectedErr)) } }) } } + +// isInvalidParameter is a minimal implementation of [github.com/docker/docker/errdefs.IsInvalidParameter], +// because this was the only import of that package in api/types, which is the +// package imported by external users. +func isInvalidParameter(err error) bool { + _, ok := err.(interface { + InvalidParameter() + }) + return ok +}