Merge pull request #49355 from thaJeztah/api_types_less_deps

api/types: remove some redundant imports
This commit is contained in:
Paweł Gronowski
2025-01-29 15:28:41 +01:00
committed by GitHub
2 changed files with 13 additions and 5 deletions

View File

@@ -3,7 +3,6 @@ package container
import ( import (
"testing" "testing"
"github.com/docker/docker/errdefs"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@@ -96,9 +95,19 @@ func TestValidateRestartPolicy(t *testing.T) {
if tc.expectedErr == "" { if tc.expectedErr == "" {
assert.Check(t, err) assert.Check(t, err)
} else { } else {
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter)) assert.Check(t, is.ErrorType(err, isInvalidParameter))
assert.Check(t, is.Error(err, tc.expectedErr)) 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
}

View File

@@ -3,10 +3,9 @@ import (
"context" "context"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"strings" "strings"
"github.com/pkg/errors"
) )
// AuthHeader is the name of the header used to send encoded registry // 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 { 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 } type errInvalidParameter struct{ error }