@@ -18,45 +18,43 @@ package main
18
18
19
19
import (
20
20
"fmt"
21
- "os"
22
- "text/tabwriter"
23
21
24
22
"github.com/Sirupsen/logrus"
25
23
"github.com/urfave/cli"
26
24
"golang.org/x/net/context"
27
25
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
28
26
)
29
27
30
- var runtimeStatusCommand = cli.Command {
31
- Name : "status" ,
32
- Usage : "Display status of the container runtime" ,
33
- ArgsUsage : "" ,
28
+ const (
29
+ criClientVersion = "v1alpha1"
30
+ )
31
+
32
+ var runtimeVersionCommand = cli.Command {
33
+ Name : "version" ,
34
+ Usage : "Display runtime version information" ,
34
35
Action : func (context * cli.Context ) error {
35
- err := Status (runtimeClient )
36
+ err := Version (runtimeClient , criClientVersion )
36
37
if err != nil {
37
- return fmt .Errorf ("Getting status of runtime failed: %v" , err )
38
+ return fmt .Errorf ("Getting the runtime version failed: %v" , err )
38
39
}
39
40
return nil
40
41
},
41
42
Before : getRuntimeClient ,
42
43
After : closeConnection ,
43
44
}
44
45
45
- // Status sends a StatusRequest to the server, and parses the returned StatusResponse .
46
- func Status (client pb.RuntimeServiceClient ) error {
47
- request := & pb.StatusRequest { }
48
- logrus .Debugf ("StatusRequest : %v" , request )
49
- r , err := client .Status (context .Background (), request )
50
- logrus .Debugf ("StatusResponse : %v" , r )
46
+ // Version sends a VersionRequest to the server, and parses the returned VersionResponse .
47
+ func Version (client pb.RuntimeServiceClient , version string ) error {
48
+ request := & pb.VersionRequest { Version : version }
49
+ logrus .Debugf ("VersionRequest : %v" , request )
50
+ r , err := client .Version (context .Background (), request )
51
+ logrus .Debugf ("VersionResponse : %v" , r )
51
52
if err != nil {
52
53
return err
53
54
}
54
-
55
- w := tabwriter .NewWriter (os .Stdout , 20 , 1 , 3 , ' ' , 0 )
56
- fmt .Fprintln (w , "CONDITION\t STATUS\t REASON\t MESSAGE" )
57
- for _ , c := range r .GetStatus ().GetConditions () {
58
- fmt .Fprintf (w , "%s\t %v\t %s\t %s\n " , c .Type , c .Status , c .Reason , c .Message )
59
- }
60
- w .Flush ()
55
+ fmt .Println ("Version: " , r .Version )
56
+ fmt .Println ("RuntimeName: " , r .RuntimeName )
57
+ fmt .Println ("RuntimeVersion: " , r .RuntimeVersion )
58
+ fmt .Println ("RuntimeApiVersion: " , r .RuntimeApiVersion )
61
59
return nil
62
60
}
0 commit comments