mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
f2614f2107
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package credentials
|
|
|
|
// ErrCredentialsNotFound standarizes the not found error, so every helper returns
|
|
// the same message and docker can handle it properly.
|
|
const errCredentialsNotFoundMessage = "credentials not found in native keychain"
|
|
|
|
// errCredentialsNotFound represents an error
|
|
// raised when credentials are not in the store.
|
|
type errCredentialsNotFound struct{}
|
|
|
|
// Error returns the standard error message
|
|
// for when the credentials are not in the store.
|
|
func (errCredentialsNotFound) Error() string {
|
|
return errCredentialsNotFoundMessage
|
|
}
|
|
|
|
// NewErrCredentialsNotFound creates a new error
|
|
// for when the credentials are not in the store.
|
|
func NewErrCredentialsNotFound() error {
|
|
return errCredentialsNotFound{}
|
|
}
|
|
|
|
// IsErrCredentialsNotFound returns true if the error
|
|
// was caused by not having a set of credentials in a store.
|
|
func IsErrCredentialsNotFound(err error) bool {
|
|
_, ok := err.(errCredentialsNotFound)
|
|
return ok
|
|
}
|
|
|
|
// IsErrCredentialsNotFoundMessage returns true if the error
|
|
// was caused by not having a set of credentials in a store.
|
|
//
|
|
// This function helps to check messages returned by an
|
|
// external program via its standard output.
|
|
func IsErrCredentialsNotFoundMessage(err string) bool {
|
|
return err == errCredentialsNotFoundMessage
|
|
}
|