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

Full implementation for OSX ready

Signed-off-by: avaid96 <avaid1996@gmail.com>
This commit is contained in:
avaid96
2016-07-11 10:50:44 -07:00
parent 5128fa1bad
commit 5a8fb214ed
7 changed files with 170 additions and 3 deletions
+28
View File
@@ -17,6 +17,11 @@ type Credentials struct {
Secret string
}
type KeyData struct{
Path string
Username string
}
// Serve initializes the credentials helper and parses the action argument.
// This function is designed to be called from a command line interface.
// It uses os.Args[1] as the key for the action.
@@ -127,3 +132,26 @@ 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
func List(helper Helper, writer io.Writer) error {
x, y, err := helper.List()
if err != nil {
return err
}
keyDataList := []KeyData{}
for index, _ := range(x) {
keyDataObj := KeyData{
Path:x[index],
Username:y[index],
}
keyDataList = append([]KeyData{keyDataObj}, keyDataList...)
}
buffer := new(bytes.Buffer)
if err := json.NewEncoder(buffer).Encode(keyDataList); err != nil {
return err
}
fmt.Fprint(writer, buffer.String())
return nil
}