mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
wincred: inline label, and append to existing
The code assumed that Attributes was always empty, so unconditionally replaced the attributes. Let's not assume that's the case (even if it is currently). Also inline the label for readability; we could optimize the byte-slice by making a package level variable, to avoid allocating, but that's probably not worth the optimzation. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
+4
-2
@@ -16,12 +16,14 @@ type Wincred struct{}
|
|||||||
|
|
||||||
// Add adds new credentials to the windows credentials manager.
|
// 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 {
|
||||||
credsLabels := []byte(credentials.CredsLabel)
|
|
||||||
g := winc.NewGenericCredential(creds.ServerURL)
|
g := winc.NewGenericCredential(creds.ServerURL)
|
||||||
g.UserName = creds.Username
|
g.UserName = creds.Username
|
||||||
g.CredentialBlob = []byte(creds.Secret)
|
g.CredentialBlob = []byte(creds.Secret)
|
||||||
g.Persist = winc.PersistLocalMachine
|
g.Persist = winc.PersistLocalMachine
|
||||||
g.Attributes = []winc.CredentialAttribute{{Keyword: "label", Value: credsLabels}}
|
g.Attributes = append(g.Attributes, winc.CredentialAttribute{
|
||||||
|
Keyword: "label",
|
||||||
|
Value: []byte(credentials.CredsLabel),
|
||||||
|
})
|
||||||
|
|
||||||
return g.Write()
|
return g.Write()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user