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

credentials: HandleCommand(): improve error for unknown command/action

- renamed the "key" variable, which was slightly confusing
- include the name of the binary in the error

Before this change:

    docker-credential-osxkeychain nosuchaction
    Unknown credential action `nosuchaction`

After this change:

    docker-credential-osxkeychain nosuchaction
    docker-credential-osxkeychain: unknown action: nosuchaction

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2023-05-28 13:32:34 +02:00
parent db0ac44c97
commit ae1d1ec013
+5 -4
View File
@@ -64,9 +64,9 @@ func usage() string {
return fmt.Sprintf("Usage: %s <store|get|erase|list|version>", Name)
}
// HandleCommand uses a helper and a key to run a credential action.
func HandleCommand(helper Helper, key string, in io.Reader, out io.Writer) error {
switch key {
// HandleCommand runs a helper to execute a credential action.
func HandleCommand(helper Helper, action string, in io.Reader, out io.Writer) error {
switch action {
case "store":
return Store(helper, in)
case "get":
@@ -77,8 +77,9 @@ func HandleCommand(helper Helper, key string, in io.Reader, out io.Writer) error
return List(helper, out)
case "version":
return PrintVersion(out)
default:
return fmt.Errorf("%s: unknown action: %s", Name, action)
}
return fmt.Errorf("Unknown credential action `%s`", key)
}
// Store uses a helper and an input reader to save credentials.