mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #49355 from thaJeztah/api_types_less_deps
api/types: remove some redundant imports
This commit is contained in:
@@ -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
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 }
|
||||||
|
|||||||
Reference in New Issue
Block a user