1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-14 00:11:28 +05:30
Files
docker-credential-helpers/wincred/wincred_windows.go
T
David Calavera c4fc9c07dd Add client functions to allow integrations within other CLIs.
This is a simplification of how the docker engine implements
this feature, but it will be ported there once this is merged.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-05-30 12:32:26 -07:00

40 lines
1.0 KiB
Go

package wincred
import (
winc "github.com/danieljoos/wincred"
"github.com/docker/docker-credential-helpers/credentials"
)
// 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 {
g := winc.NewGenericCredential(creds.ServerURL)
g.UserName = creds.Username
g.CredentialBlob = []byte(creds.Secret)
g.Persist = winc.PersistLocalMachine
return g.Write()
}
// Delete removes credentials from the windows credentials manager.
func (h Wincred) Delete(serverURL string) error {
g, err := winc.GetGenericCredential(serverURL)
if g == nil {
return nil
}
if err != nil {
return err
}
return g.Delete()
}
// Get retrieves credentials from the windows credentials manager.
func (h Wincred) Get(serverURL string) (string, string, error) {
g, _ := winc.GetGenericCredential(serverURL)
if g == nil {
return "", "", credentials.NewErrCredentialsNotFound()
}
return g.UserName, string(g.CredentialBlob), nil
}