1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-13 16:01:28 +05:30

Implement client.List, change list API

[]string, []string -> map[string]string because the other APIs assume a
1:1 correspondence

Signed-off-by: Jake Sanders <jsand@google.com>
This commit is contained in:
Jake Sanders
2016-09-02 15:12:18 -07:00
parent 80833adff5
commit c45d9e9e28
11 changed files with 71 additions and 75 deletions
+11 -5
View File
@@ -68,14 +68,20 @@ func Erase(program ProgramFunc, serverURL string) error {
return nil
}
// List executes a program to remove the server credentials from the native store.
func List(program ProgramFunc) error {
// List executes a program to list server credentials in the native store.
func List(program ProgramFunc) (map[string]string, error) {
cmd := program("list")
cmd.Input(strings.NewReader("garbage"))
cmd.Input(strings.NewReader("unused"))
out, err := cmd.Output()
if err != nil {
t := strings.TrimSpace(string(out))
return fmt.Errorf("error listing credentials - err: %v, out: `%s`", err, t)
return nil, fmt.Errorf("error listing credentials - err: %v, out: `%s`", err, t)
}
return nil
var resp map[string]string
if err = json.NewDecoder(bytes.NewReader(out)).Decode(&resp); err != nil {
return nil, err
}
return resp, nil
}