forked from containerd/containerd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
43 lines (39 loc) · 963 Bytes
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
gocontext "context"
"fmt"
"os"
"github.com/containerd/containerd/version"
"github.com/urfave/cli"
)
var versionCommand = cli.Command{
Name: "version",
Usage: "print the version",
Action: func(context *cli.Context) error {
if context.NArg() > 0 {
return fmt.Errorf("no argument expected")
}
fmt.Println("Client:")
fmt.Printf(" Version: %s\n", version.Version)
fmt.Printf(" Revision: %s\n", version.Revision)
fmt.Println("")
client, err := newClient(context)
if err != nil {
return err
}
v, err := client.Version(gocontext.Background())
if err != nil {
return err
}
fmt.Println("Server:")
fmt.Printf(" Version: %s\n", v.Version)
fmt.Printf(" Revision: %s\n", v.Revision)
if v.Version != version.Version {
fmt.Fprintf(os.Stderr, "WARNING: version mismatch\n")
}
if v.Revision != version.Revision {
fmt.Fprintf(os.Stderr, "WARNING: revision mismatch\n")
}
return nil
},
}