Use protoversion for containerd version
Signed-off-by: Peter Edge <peter.edge@gmail.com>
This commit is contained in:
parent
1d63236c27
commit
d2e319523d
5 changed files with 48 additions and 4 deletions
|
@ -23,6 +23,10 @@ import (
|
|||
|
||||
// TODO: parse flags and pass opts
|
||||
func getClient(ctx *cli.Context) types.APIClient {
|
||||
return types.NewAPIClient(getClientConn(ctx))
|
||||
}
|
||||
|
||||
func getClientConn(ctx *cli.Context) *grpc.ClientConn {
|
||||
dialOpts := []grpc.DialOption{grpc.WithInsecure()}
|
||||
dialOpts = append(dialOpts,
|
||||
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
||||
|
@ -33,7 +37,7 @@ func getClient(ctx *cli.Context) types.APIClient {
|
|||
if err != nil {
|
||||
fatal(err.Error(), 1)
|
||||
}
|
||||
return types.NewAPIClient(conn)
|
||||
return conn
|
||||
}
|
||||
|
||||
var ContainersCommand = cli.Command{
|
||||
|
|
|
@ -14,7 +14,7 @@ const Usage = `High performance container daemon cli`
|
|||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "ctr"
|
||||
app.Version = containerd.Version
|
||||
app.Version = containerd.Version.VersionString()
|
||||
app.Usage = Usage
|
||||
app.Authors = []cli.Author{
|
||||
{
|
||||
|
@ -37,6 +37,7 @@ func main() {
|
|||
CheckpointCommand,
|
||||
ContainersCommand,
|
||||
EventsCommand,
|
||||
VersionCommand,
|
||||
}
|
||||
app.Before = func(context *cli.Context) error {
|
||||
if context.GlobalBool("debug") {
|
||||
|
|
22
ctr/version.go
Normal file
22
ctr/version.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"go.pedge.io/proto/version"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/docker/containerd"
|
||||
)
|
||||
|
||||
var VersionCommand = cli.Command{
|
||||
Name: "version",
|
||||
Usage: "get the containerd version",
|
||||
Action: func(context *cli.Context) {
|
||||
serverVersion, err := protoversion.GetServerVersion(getClientConn(context))
|
||||
if err != nil {
|
||||
fatal(err.Error(), 1)
|
||||
}
|
||||
fmt.Printf("Client: %s\nServer: %s\n", containerd.Version.VersionString(), serverVersion.VersionString())
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue