@@ -11,17 +11,18 @@ import (
1111 "github.com/docker/docker-credential-helpers/registryurl"
1212)
1313
14+ var credsLabel = []byte (credentials .CredsLabel )
15+
1416// Wincred handles secrets using the Windows credential service.
1517type Wincred struct {}
1618
1719// Add adds new credentials to the windows credentials manager.
1820func (h Wincred ) Add (creds * credentials.Credentials ) error {
19- credsLabels := []byte (credentials .CredsLabel )
2021 g := winc .NewGenericCredential (creds .ServerURL )
2122 g .UserName = creds .Username
2223 g .CredentialBlob = []byte (creds .Secret )
2324 g .Persist = winc .PersistLocalMachine
24- g .Attributes = []winc.CredentialAttribute {{Keyword : "label" , Value : credsLabels }}
25+ g .Attributes = []winc.CredentialAttribute {{Keyword : "label" , Value : credsLabel }}
2526
2627 return g .Write ()
2728}
@@ -53,7 +54,7 @@ func (h Wincred) Get(serverURL string) (string, string, error) {
5354 }
5455
5556 for _ , attr := range g .Attributes {
56- if attr .Keyword == "label" && bytes .Equal (attr .Value , [] byte ( credentials . CredsLabel ) ) {
57+ if attr .Keyword == "label" && bytes .Equal (attr .Value , credsLabel ) {
5758 return g .UserName , string (g .CredentialBlob ), nil
5859 }
5960 }
@@ -74,7 +75,7 @@ func getTarget(serverURL string) (string, error) {
7475 var targets []string
7576 for _ , cred := range creds {
7677 for _ , attr := range cred .Attributes {
77- if attr .Keyword == "label" && bytes .Equal (attr .Value , [] byte ( credentials . CredsLabel ) ) {
78+ if attr .Keyword == "label" && bytes .Equal (attr .Value , credsLabel ) {
7879 targets = append (targets , cred .TargetName )
7980 }
8081 }
@@ -135,7 +136,7 @@ func (h Wincred) List() (map[string]string, error) {
135136
136137 for _ , cred := range creds {
137138 for _ , attr := range cred .Attributes {
138- if attr .Keyword == "label" && bytes .Equal (attr .Value , [] byte ( credentials . CredsLabel ) ) {
139+ if attr .Keyword == "label" && bytes .Equal (attr .Value , credsLabel ) {
139140 resp [cred .TargetName ] = cred .UserName
140141 break
141142 }
0 commit comments