mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
Add a Docker Credentials label to store and list creds
Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
This commit is contained in:
@@ -12,11 +12,16 @@ import (
|
|||||||
|
|
||||||
// Credentials holds the information shared between docker and the credentials store.
|
// Credentials holds the information shared between docker and the credentials store.
|
||||||
type Credentials struct {
|
type Credentials struct {
|
||||||
|
Label string
|
||||||
ServerURL string
|
ServerURL string
|
||||||
Username string
|
Username string
|
||||||
Secret string
|
Secret string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Docker credentials should be labeled as such in credential stores, this label
|
||||||
|
// allow us to filter out non-Docker credentials at lookup
|
||||||
|
const CredsLabel = "Docker Credentials"
|
||||||
|
|
||||||
// Serve initializes the credentials helper and parses the action argument.
|
// Serve initializes the credentials helper and parses the action argument.
|
||||||
// This function is designed to be called from a command line interface.
|
// This function is designed to be called from a command line interface.
|
||||||
// It uses os.Args[1] as the key for the action.
|
// It uses os.Args[1] as the key for the action.
|
||||||
@@ -72,6 +77,8 @@ func Store(helper Helper, reader io.Reader) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
creds.Label = CredsLabel
|
||||||
|
|
||||||
return helper.Add(&creds)
|
return helper.Add(&creds)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +140,7 @@ func Erase(helper Helper, reader io.Reader) error {
|
|||||||
//List returns all the serverURLs of keys in
|
//List returns all the serverURLs of keys in
|
||||||
//the OS store as a list of strings
|
//the OS store as a list of strings
|
||||||
func List(helper Helper, writer io.Writer) error {
|
func List(helper Helper, writer io.Writer) error {
|
||||||
accts, err := helper.List()
|
accts, err := helper.List(CredsLabel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (m *memoryStore) Get(serverURL string) (string, string, error) {
|
|||||||
return c.Username, c.Secret, nil
|
return c.Username, c.Secret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *memoryStore) List() (map[string]string, error) {
|
func (m *memoryStore) List(credsLabel string) (map[string]string, error) {
|
||||||
//Simply a placeholder to let memoryStore be a valid implementation of Helper interface
|
//Simply a placeholder to let memoryStore be a valid implementation of Helper interface
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ type Helper interface {
|
|||||||
// Get retrieves credentials from the store.
|
// Get retrieves credentials from the store.
|
||||||
// It returns username and secret as strings.
|
// It returns username and secret as strings.
|
||||||
Get(serverURL string) (string, string, error)
|
Get(serverURL string) (string, string, error)
|
||||||
// List returns the stored serverURLs and their associated usernames.
|
// List returns the stored serverURLs and their associated usernames
|
||||||
List() (map[string]string, error)
|
// for a given credentials label.
|
||||||
|
List(credsLabel string) (map[string]string, error)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user