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

Publish helper structs and methods.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera
2016-03-24 15:08:17 -07:00
parent 4b8917b1cf
commit df8c7a02f1
9 changed files with 25 additions and 37 deletions
+1 -1
View File
@@ -6,5 +6,5 @@ import (
)
func main() {
credentials.Serve(osxkeychain.New())
credentials.Serve(osxkeychain.Osxkeychain{})
}
+5 -9
View File
@@ -22,15 +22,11 @@ import (
// when the credentials are not in the keychain.
const errCredentialsNotFound = "The specified item could not be found in the keychain."
type osxkeychain struct{}
// New creates a new osxkeychain.
func New() credentials.Helper {
return osxkeychain{}
}
// Osxkeychain handles secrets using the OS X Keychain as store.
type Osxkeychain struct{}
// Add adds new credentials to the keychain.
func (h osxkeychain) Add(creds *credentials.Credentials) error {
func (h Osxkeychain) Add(creds *credentials.Credentials) error {
s, err := splitServer(creds.ServerURL)
if err != nil {
return err
@@ -52,7 +48,7 @@ func (h osxkeychain) Add(creds *credentials.Credentials) error {
}
// Delete removes credentials from the keychain.
func (h osxkeychain) Delete(serverURL string) error {
func (h Osxkeychain) Delete(serverURL string) error {
s, err := splitServer(serverURL)
if err != nil {
return err
@@ -69,7 +65,7 @@ func (h osxkeychain) Delete(serverURL string) error {
}
// Get returns the username and secret to use for a given registry server URL.
func (h osxkeychain) Get(serverURL string) (string, string, error) {
func (h Osxkeychain) Get(serverURL string) (string, string, error) {
s, err := splitServer(serverURL)
if err != nil {
return "", "", err
+2 -2
View File
@@ -13,7 +13,7 @@ func TestOSXKeychainHelper(t *testing.T) {
Secret: "foobarbaz",
}
helper := New()
helper := Osxkeychain{}
if err := helper.Add(creds); err != nil {
t.Fatal(err)
}
@@ -37,7 +37,7 @@ func TestOSXKeychainHelper(t *testing.T) {
}
func TestMissingCredentials(t *testing.T) {
helper := New()
helper := Osxkeychain{}
_, _, err := helper.Get("https://adsfasdf.wrewerwer.com/asdfsdddd")
if err != credentials.ErrCredentialsNotFound {
t.Fatalf("exptected ErrCredentialsNotFound, got %v", err)