1- // A `pass` based credential helper. Passwords are stored as arguments to pass
2- // of the form: "$PASS_FOLDER/base64-url(serverURL)/username". We base64-url
3- // encode the serverURL, because under the hood pass uses files and folders, so
4- // /s will get translated into additional folders.
1+ // Package pass implements a `pass` based credential helper. Passwords are stored
2+ // as arguments to pass of the form: "$PASS_FOLDER/base64-url(serverURL)/username".
3+ // We base64-url encode the serverURL, because under the hood pass uses files and
4+ // folders, so /s will get translated into additional folders.
55package pass
66
77import (
@@ -19,7 +19,8 @@ import (
1919 "github.com/docker/docker-credential-helpers/credentials"
2020)
2121
22- const PASS_FOLDER = "docker-credential-helpers"
22+ // PASS_FOLDER contains the directory where credentials are stored
23+ const PASS_FOLDER = "docker-credential-helpers" //nolint: golint
2324
2425// Pass handles secrets using Linux secret-service as a store.
2526type Pass struct {}
@@ -79,25 +80,25 @@ func (p Pass) runPassHelper(stdinContent string, args ...string) (string, error)
7980}
8081
8182// Add adds new credentials to the keychain.
82- func (h Pass ) Add (creds * credentials.Credentials ) error {
83+ func (p Pass ) Add (creds * credentials.Credentials ) error {
8384 if creds == nil {
8485 return errors .New ("missing credentials" )
8586 }
8687
8788 encoded := base64 .URLEncoding .EncodeToString ([]byte (creds .ServerURL ))
8889
89- _ , err := h .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , creds .Username ))
90+ _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , creds .Username ))
9091 return err
9192}
9293
9394// Delete removes credentials from the store.
94- func (h Pass ) Delete (serverURL string ) error {
95+ func (p Pass ) Delete (serverURL string ) error {
9596 if serverURL == "" {
9697 return errors .New ("missing server url" )
9798 }
9899
99100 encoded := base64 .URLEncoding .EncodeToString ([]byte (serverURL ))
100- _ , err := h .runPass ("" , "rm" , "-rf" , path .Join (PASS_FOLDER , encoded ))
101+ _ , err := p .runPass ("" , "rm" , "-rf" , path .Join (PASS_FOLDER , encoded ))
101102 return err
102103}
103104
@@ -128,7 +129,7 @@ func listPassDir(args ...string) ([]os.FileInfo, error) {
128129}
129130
130131// Get returns the username and secret to use for a given registry server URL.
131- func (h Pass ) Get (serverURL string ) (string , string , error ) {
132+ func (p Pass ) Get (serverURL string ) (string , string , error ) {
132133 if serverURL == "" {
133134 return "" , "" , errors .New ("missing server url" )
134135 }
@@ -153,12 +154,12 @@ func (h Pass) Get(serverURL string) (string, string, error) {
153154 }
154155
155156 actual := strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
156- secret , err := h .runPass ("" , "show" , path .Join (PASS_FOLDER , encoded , actual ))
157+ secret , err := p .runPass ("" , "show" , path .Join (PASS_FOLDER , encoded , actual ))
157158 return actual , secret , err
158159}
159160
160161// List returns the stored URLs and corresponding usernames for a given credentials label
161- func (h Pass ) List () (map [string ]string , error ) {
162+ func (p Pass ) List () (map [string ]string , error ) {
162163 servers , err := listPassDir ()
163164 if err != nil {
164165 return nil , err
0 commit comments