mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
return "" instead of an error when pass isn't present
It turns out the cred helpers protocol is to return "" and not an error when a credential isn't present, so let's do that. Signed-off-by: Tycho Andersen <tycho@docker.com>
This commit is contained in:
+17
-4
@@ -111,10 +111,7 @@ func (h Pass) Delete(serverURL string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// listPassDir lists all the contents of a directory in the password store.
|
func getPassDir() string {
|
||||||
// Pass uses fancy unicode to emit stuff to stdout, so rather than try
|
|
||||||
// and parse this, let's just look at the directory structure instead.
|
|
||||||
func listPassDir(args ...string) ([]os.FileInfo, error) {
|
|
||||||
passDir := os.ExpandEnv("$HOME/.password-store")
|
passDir := os.ExpandEnv("$HOME/.password-store")
|
||||||
for _, e := range os.Environ() {
|
for _, e := range os.Environ() {
|
||||||
parts := strings.SplitN(e, "=", 2)
|
parts := strings.SplitN(e, "=", 2)
|
||||||
@@ -130,6 +127,14 @@ func listPassDir(args ...string) ([]os.FileInfo, error) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return passDir
|
||||||
|
}
|
||||||
|
|
||||||
|
// listPassDir lists all the contents of a directory in the password store.
|
||||||
|
// Pass uses fancy unicode to emit stuff to stdout, so rather than try
|
||||||
|
// and parse this, let's just look at the directory structure instead.
|
||||||
|
func listPassDir(args ...string) ([]os.FileInfo, error) {
|
||||||
|
passDir := getPassDir()
|
||||||
p := path.Join(append([]string{passDir, PASS_FOLDER}, args...)...)
|
p := path.Join(append([]string{passDir, PASS_FOLDER}, args...)...)
|
||||||
contents, err := ioutil.ReadDir(p)
|
contents, err := ioutil.ReadDir(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -155,6 +160,14 @@ func (h Pass) Get(serverURL string) (string, string, error) {
|
|||||||
|
|
||||||
encoded := base64.URLEncoding.EncodeToString([]byte(serverURL))
|
encoded := base64.URLEncoding.EncodeToString([]byte(serverURL))
|
||||||
|
|
||||||
|
if _, err := os.Stat(path.Join(getPassDir(), PASS_FOLDER, encoded)); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return "", "", nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
|
||||||
usernames, err := listPassDir(encoded)
|
usernames, err := listPassDir(encoded)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
|
|||||||
Reference in New Issue
Block a user