mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
cleaned up some of the osx code, added a better test for list
Signed-off-by: avaid96 <avaid1996@gmail.com>
This commit is contained in:
+10
-10
@@ -17,9 +17,9 @@ type Credentials struct {
|
||||
Secret string
|
||||
}
|
||||
|
||||
type KeyData struct{
|
||||
Path string
|
||||
Username string
|
||||
type KeyData struct {
|
||||
Path string
|
||||
Username string
|
||||
}
|
||||
|
||||
// Serve initializes the credentials helper and parses the action argument.
|
||||
@@ -133,18 +133,18 @@ func Erase(helper Helper, reader io.Reader) error {
|
||||
return helper.Delete(serverURL)
|
||||
}
|
||||
|
||||
//List returns all the serverURLs of keys in
|
||||
//the OS store as a list of strings
|
||||
//List returns all the serverURLs of keys in
|
||||
//the OS store as a list of strings
|
||||
func List(helper Helper, writer io.Writer) error {
|
||||
x, y, err := helper.List()
|
||||
paths, accts, err := helper.List()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
keyDataList := []KeyData{}
|
||||
for index, _ := range(x) {
|
||||
for index := 0; index < len(paths); index++ {
|
||||
keyDataObj := KeyData{
|
||||
Path:x[index],
|
||||
Username:y[index],
|
||||
Path: paths[index],
|
||||
Username: accts[index],
|
||||
}
|
||||
keyDataList = append([]KeyData{keyDataObj}, keyDataList...)
|
||||
}
|
||||
@@ -154,4 +154,4 @@ func List(helper Helper, writer io.Writer) error {
|
||||
}
|
||||
fmt.Fprint(writer, buffer.String())
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ func TestList(t *testing.T) {
|
||||
if err := List(h, out); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
//testing that there is an output
|
||||
if out.Len() == 0 {
|
||||
t.Fatalf("expected output in the writer, got %d", 0)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ type Helper interface {
|
||||
// Get retrieves credentials from the store.
|
||||
// It returns username and secret as strings.
|
||||
Get(serverURL string) (string, string, error)
|
||||
// List returns all the serverURLs of keys in
|
||||
// the OS store as a list of strings
|
||||
// List returns the serverURLs of keys and their
|
||||
// associated usernames from the OS store as a
|
||||
// list of strings
|
||||
List() ([]string, []string, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user