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:
@@ -64,9 +64,9 @@ func usage() string {
|
|||||||
return fmt.Sprintf("Usage: %s <store|get|erase|list|version>", Name)
|
return fmt.Sprintf("Usage: %s <store|get|erase|list|version>", Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleCommand uses a helper and a key to run a credential action.
|
// HandleCommand runs a helper to execute a credential action.
|
||||||
func HandleCommand(helper Helper, key string, in io.Reader, out io.Writer) error {
|
func HandleCommand(helper Helper, action string, in io.Reader, out io.Writer) error {
|
||||||
switch key {
|
switch action {
|
||||||
case "store":
|
case "store":
|
||||||
return Store(helper, in)
|
return Store(helper, in)
|
||||||
case "get":
|
case "get":
|
||||||
@@ -77,8 +77,9 @@ func HandleCommand(helper Helper, key string, in io.Reader, out io.Writer) error
|
|||||||
return List(helper, out)
|
return List(helper, out)
|
||||||
case "version":
|
case "version":
|
||||||
return PrintVersion(out)
|
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.
|
// Store uses a helper and an input reader to save credentials.
|
||||||
|
|||||||
Reference in New Issue
Block a user