Add new version command to ctr
This method allow retrieving the target daemon version information. Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
ba465c17a7
commit
efc47463cd
1 changed files with 17 additions and 0 deletions
17
ctr/main.go
17
ctr/main.go
|
@ -5,9 +5,12 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
netcontext "golang.org/x/net/context"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"github.com/docker/containerd"
|
"github.com/docker/containerd"
|
||||||
|
"github.com/docker/containerd/api/grpc/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const usage = `High performance container daemon cli`
|
const usage = `High performance container daemon cli`
|
||||||
|
@ -55,6 +58,7 @@ func main() {
|
||||||
containersCommand,
|
containersCommand,
|
||||||
eventsCommand,
|
eventsCommand,
|
||||||
stateCommand,
|
stateCommand,
|
||||||
|
versionCommand,
|
||||||
}
|
}
|
||||||
app.Before = func(context *cli.Context) error {
|
app.Before = func(context *cli.Context) error {
|
||||||
if context.GlobalBool("debug") {
|
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) {
|
func fatal(err string, code int) {
|
||||||
fmt.Fprintf(os.Stderr, "[ctr] %s\n", err)
|
fmt.Fprintf(os.Stderr, "[ctr] %s\n", err)
|
||||||
panic(Exit{code})
|
panic(Exit{code})
|
||||||
|
|
Loading…
Reference in a new issue