mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-13 16:01:28 +05:30
Move away from password as a name. We store secrets.
Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
type credentialsGetResponse struct {
|
||||
Username string
|
||||
Password string
|
||||
Secret string
|
||||
}
|
||||
|
||||
// Serve initializes the credentials helper and parses the action argument.
|
||||
@@ -73,14 +73,14 @@ func get(helper Helper, reader io.Reader, writer io.Writer) error {
|
||||
|
||||
serverURL := strings.TrimSpace(buffer.String())
|
||||
|
||||
username, password, err := helper.Get(serverURL)
|
||||
username, secret, err := helper.Get(serverURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp := credentialsGetResponse{
|
||||
Username: username,
|
||||
Password: password,
|
||||
Secret: secret,
|
||||
}
|
||||
|
||||
buffer.Reset()
|
||||
|
||||
@@ -33,7 +33,7 @@ func (m *memoryStore) Get(serverURL string) (string, string, error) {
|
||||
if !ok {
|
||||
return "", "", fmt.Errorf("creds not found for %s", serverURL)
|
||||
}
|
||||
return c.Username, c.Password, nil
|
||||
return c.Username, c.Secret, nil
|
||||
}
|
||||
|
||||
func TestStore(t *testing.T) {
|
||||
@@ -41,7 +41,7 @@ func TestStore(t *testing.T) {
|
||||
creds := &Credentials{
|
||||
ServerURL: serverURL,
|
||||
Username: "foo",
|
||||
Password: "bar",
|
||||
Secret: "bar",
|
||||
}
|
||||
b, err := json.Marshal(creds)
|
||||
if err != nil {
|
||||
@@ -63,8 +63,8 @@ func TestStore(t *testing.T) {
|
||||
t.Fatalf("expected username foo, got %s\n", c.Username)
|
||||
}
|
||||
|
||||
if c.Password != "bar" {
|
||||
t.Fatalf("expected username bar, got %s\n", c.Password)
|
||||
if c.Secret != "bar" {
|
||||
t.Fatalf("expected username bar, got %s\n", c.Secret)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestGet(t *testing.T) {
|
||||
creds := &Credentials{
|
||||
ServerURL: serverURL,
|
||||
Username: "foo",
|
||||
Password: "bar",
|
||||
Secret: "bar",
|
||||
}
|
||||
b, err := json.Marshal(creds)
|
||||
if err != nil {
|
||||
@@ -105,8 +105,8 @@ func TestGet(t *testing.T) {
|
||||
t.Fatalf("expected username foo, got %s\n", c.Username)
|
||||
}
|
||||
|
||||
if c.Password != "bar" {
|
||||
t.Fatalf("expected username bar, got %s\n", c.Password)
|
||||
if c.Secret != "bar" {
|
||||
t.Fatalf("expected username bar, got %s\n", c.Secret)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ func TestErase(t *testing.T) {
|
||||
creds := &Credentials{
|
||||
ServerURL: serverURL,
|
||||
Username: "foo",
|
||||
Password: "bar",
|
||||
Secret: "bar",
|
||||
}
|
||||
b, err := json.Marshal(creds)
|
||||
if err != nil {
|
||||
|
||||
@@ -6,7 +6,7 @@ import "errors"
|
||||
type Credentials struct {
|
||||
ServerURL string
|
||||
Username string
|
||||
Password string
|
||||
Secret string
|
||||
}
|
||||
|
||||
// Helper is the interface a credentials store helper must implement.
|
||||
|
||||
Reference in New Issue
Block a user