1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-13 07:51:32 +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:
Sebastiaan van Stijn
2026-04-20 19:13:52 +02:00
parent 312e321de7
commit 869b277af1
+4 -2
View File
@@ -16,12 +16,14 @@ type Wincred struct{}
// Add adds new credentials to the windows credentials manager.
func (h Wincred) Add(creds *credentials.Credentials) error {
credsLabels := []byte(credentials.CredsLabel)
g := winc.NewGenericCredential(creds.ServerURL)
g.UserName = creds.Username
g.CredentialBlob = []byte(creds.Secret)
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()
}