Skip to content

Commit ae1d1ec

Browse files
committed
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 <[email protected]>
1 parent db0ac44 commit ae1d1ec

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

credentials/credentials.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ func usage() string {
6464
return fmt.Sprintf("Usage: %s <store|get|erase|list|version>", Name)
6565
}
6666

67-
// HandleCommand uses a helper and a key to run a credential action.
68-
func HandleCommand(helper Helper, key string, in io.Reader, out io.Writer) error {
69-
switch key {
67+
// HandleCommand runs a helper to execute a credential action.
68+
func HandleCommand(helper Helper, action string, in io.Reader, out io.Writer) error {
69+
switch action {
7070
case "store":
7171
return Store(helper, in)
7272
case "get":
@@ -77,8 +77,9 @@ func HandleCommand(helper Helper, key string, in io.Reader, out io.Writer) error
7777
return List(helper, out)
7878
case "version":
7979
return PrintVersion(out)
80+
default:
81+
return fmt.Errorf("%s: unknown action: %s", Name, action)
8082
}
81-
return fmt.Errorf("Unknown credential action `%s`", key)
8283
}
8384

8485
// Store uses a helper and an input reader to save credentials.

0 commit comments

Comments
 (0)