diff --git a/ctr/main.go b/ctr/main.go index 06910ca..a2f7891 100644 --- a/ctr/main.go +++ b/ctr/main.go @@ -5,9 +5,12 @@ import ( "os" "time" + netcontext "golang.org/x/net/context" + "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" "github.com/docker/containerd" + "github.com/docker/containerd/api/grpc/types" ) const usage = `High performance container daemon cli` @@ -55,6 +58,7 @@ func main() { containersCommand, eventsCommand, stateCommand, + versionCommand, } app.Before = func(context *cli.Context) error { if context.GlobalBool("debug") { @@ -67,6 +71,19 @@ func main() { } } +var versionCommand = cli.Command{ + Name: "version", + Usage: "return the daemon version", + Action: func(context *cli.Context) { + c := getClient(context) + resp, err := c.GetServerVersion(netcontext.Background(), &types.GetServerVersionRequest{}) + if err != nil { + fatal(err.Error(), 1) + } + fmt.Printf("daemon version %d.%d.%d commit: %s\n", resp.Major, resp.Minor, resp.Patch, resp.Revision) + }, +} + func fatal(err string, code int) { fmt.Fprintf(os.Stderr, "[ctr] %s\n", err) panic(Exit{code})