1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-13 16:01:28 +05:30

Implement credential programs reading from Stdin.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera
2016-02-09 10:53:34 -08:00
parent de9748d6ed
commit f4a0e81b0b
7 changed files with 266 additions and 71 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ char *get_error(OSStatus status) {
char *buf = malloc(128);
CFStringRef str = SecCopyErrorMessageString(status, NULL);
int success = CFStringGetCString(str, buf, 128, kCFStringEncodingUTF8);
if (success) {
if (!success) {
strncpy(buf, "Unknown error", 128);
}
return buf;
+11 -1
View File
@@ -18,6 +18,10 @@ import (
"github.com/calavera/docker-credential-helpers/credentials"
)
// notFoundError is the specific error message returned by OS X
// when the credentials are not in the keychain.
const notFoundError = "The specified item could not be found in the keychain."
type osxkeychain struct{}
// New creates a new osxkeychain.
@@ -82,7 +86,13 @@ func (h osxkeychain) Get(serverURL string) (string, string, error) {
errMsg := C.keychain_get(s, &usernameLen, &username, &passwordLen, &password)
if errMsg != nil {
defer C.free(unsafe.Pointer(errMsg))
return "", "", errors.New(C.GoString(errMsg))
goMsg := C.GoString(errMsg)
if goMsg == notFoundError {
return "", "", credentials.NotFoundError
}
return "", "", errors.New(goMsg)
}
user := C.GoStringN(username, C.int(usernameLen))