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

Add a version command

Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
This commit is contained in:
Jean-Laurent de Morlhon
2017-05-30 09:45:00 +02:00
parent 607bf3c174
commit 4d60b372aa
2 changed files with 15 additions and 3 deletions
+9 -1
View File
@@ -50,7 +50,7 @@ func SetCredsLabel(label string) {
func Serve(helper Helper) {
var err error
if len(os.Args) != 2 {
err = fmt.Errorf("Usage: %s <store|get|erase|list>", os.Args[0])
err = fmt.Errorf("Usage: %s <store|get|erase|list|version>", os.Args[0])
}
if err == nil {
@@ -74,6 +74,8 @@ func HandleCommand(helper Helper, key string, in io.Reader, out io.Writer) error
return Erase(helper, in)
case "list":
return List(helper, out)
case "version":
return PrintVersion(out)
}
return fmt.Errorf("Unknown credential action `%s`", key)
}
@@ -175,3 +177,9 @@ func List(helper Helper, writer io.Writer) error {
}
return json.NewEncoder(writer).Encode(accts)
}
//PrintVersion outputs the current version.
func PrintVersion(writer io.Writer) error {
fmt.Fprintln(writer, Version)
return nil
}
+4
View File
@@ -0,0 +1,4 @@
package credentials
// Version holds a string describing the current version
const Version = "0.5.1"