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(wincred.New())
credentials.Serve(wincred.Wincred{})
}
+5 -9
View File
@@ -5,15 +5,11 @@ import (
"github.com/docker/docker-credential-helpers/credentials"
)
type wincred struct{}
// New creates a new wincred.
func New() credentials.Helper {
return wincred{}
}
// Wincred handles secrets using the Windows credential service.
type Wincred struct{}
// Add adds new credentials to the windows credentials manager.
func (h wincred) Add(creds *credentials.Credentials) error {
func (h Wincred) Add(creds *credentials.Credentials) error {
g := winc.NewGenericCredential(creds.ServerURL)
g.UserName = creds.Username
g.CredentialBlob = []byte(creds.Secret)
@@ -22,7 +18,7 @@ func (h wincred) Add(creds *credentials.Credentials) error {
}
// Delete removes credentials from the windows credentials manager.
func (h wincred) Delete(serverURL string) error {
func (h Wincred) Delete(serverURL string) error {
g, err := winc.GetGenericCredential(serverURL)
if g == nil {
return nil
@@ -34,7 +30,7 @@ func (h wincred) Delete(serverURL string) error {
}
// Get retrieves credentials from the windows credentials manager.
func (h wincred) Get(serverURL string) (string, string, error) {
func (h Wincred) Get(serverURL string) (string, string, error) {
g, _ := winc.GetGenericCredential(serverURL)
if g == nil {
return "", "", credentials.ErrCredentialsNotFound
+2 -2
View File
@@ -13,7 +13,7 @@ func TestWinCredHelper(t *testing.T) {
Secret: "foobarbaz",
}
helper := New()
helper := Wincred{}
if err := helper.Add(creds); err != nil {
t.Fatal(err)
}
@@ -37,7 +37,7 @@ func TestWinCredHelper(t *testing.T) {
}
func TestMissingCredentials(t *testing.T) {
helper := New()
helper := Wincred{}
_, _, err := helper.Get("https://adsfasdf.wrewerwer.com/asdfsdddd")
if err != credentials.ErrCredentialsNotFound {
t.Fatalf("exptected ErrCredentialsNotFound, got %v", err)