mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
credentials: use errors.As() to match error-types
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package credentials
|
package credentials
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// ErrCredentialsNotFound standardizes the not found error, so every helper returns
|
// ErrCredentialsNotFound standardizes the not found error, so every helper returns
|
||||||
// the same message and docker can handle it properly.
|
// the same message and docker can handle it properly.
|
||||||
@@ -30,8 +32,8 @@ func NewErrCredentialsNotFound() error {
|
|||||||
// IsErrCredentialsNotFound returns true if the error
|
// IsErrCredentialsNotFound returns true if the error
|
||||||
// was caused by not having a set of credentials in a store.
|
// was caused by not having a set of credentials in a store.
|
||||||
func IsErrCredentialsNotFound(err error) bool {
|
func IsErrCredentialsNotFound(err error) bool {
|
||||||
_, ok := err.(errCredentialsNotFound)
|
var target errCredentialsNotFound
|
||||||
return ok
|
return errors.As(err, &target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsErrCredentialsNotFoundMessage returns true if the error
|
// IsErrCredentialsNotFoundMessage returns true if the error
|
||||||
@@ -78,8 +80,8 @@ func NewErrCredentialsMissingUsername() error {
|
|||||||
// IsCredentialsMissingServerURL returns true if the error
|
// IsCredentialsMissingServerURL returns true if the error
|
||||||
// was an errCredentialsMissingServerURL.
|
// was an errCredentialsMissingServerURL.
|
||||||
func IsCredentialsMissingServerURL(err error) bool {
|
func IsCredentialsMissingServerURL(err error) bool {
|
||||||
_, ok := err.(errCredentialsMissingServerURL)
|
var target errCredentialsMissingServerURL
|
||||||
return ok
|
return errors.As(err, &target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsCredentialsMissingServerURLMessage checks for an
|
// IsCredentialsMissingServerURLMessage checks for an
|
||||||
@@ -91,8 +93,8 @@ func IsCredentialsMissingServerURLMessage(err string) bool {
|
|||||||
// IsCredentialsMissingUsername returns true if the error
|
// IsCredentialsMissingUsername returns true if the error
|
||||||
// was an errCredentialsMissingUsername.
|
// was an errCredentialsMissingUsername.
|
||||||
func IsCredentialsMissingUsername(err error) bool {
|
func IsCredentialsMissingUsername(err error) bool {
|
||||||
_, ok := err.(errCredentialsMissingUsername)
|
var target errCredentialsMissingUsername
|
||||||
return ok
|
return errors.As(err, &target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsCredentialsMissingUsernameMessage checks for an
|
// IsCredentialsMissingUsernameMessage checks for an
|
||||||
|
|||||||
Reference in New Issue
Block a user