@@ -17,6 +17,8 @@ limitations under the License.
17
17
package main
18
18
19
19
import (
20
+ "bytes"
21
+ "encoding/json"
20
22
"fmt"
21
23
"os"
22
24
"text/tabwriter"
@@ -29,10 +31,16 @@ import (
29
31
30
32
var runtimeStatusCommand = cli.Command {
31
33
Name : "status" ,
32
- Usage : "Display status of the container runtime" ,
34
+ Usage : "Display status and extra information of the container runtime" ,
33
35
ArgsUsage : "" ,
36
+ Flags : []cli.Flag {
37
+ cli.BoolFlag {
38
+ Name : "verbose, v" ,
39
+ Usage : "Shows extra status information" ,
40
+ },
41
+ },
34
42
Action : func (context * cli.Context ) error {
35
- err := Status (runtimeClient )
43
+ err := Status (runtimeClient , context . Bool ( "verbose" ) )
36
44
if err != nil {
37
45
return fmt .Errorf ("Getting status of runtime failed: %v" , err )
38
46
}
@@ -43,8 +51,8 @@ var runtimeStatusCommand = cli.Command{
43
51
}
44
52
45
53
// Status sends a StatusRequest to the server, and parses the returned StatusResponse.
46
- func Status (client pb.RuntimeServiceClient ) error {
47
- request := & pb.StatusRequest {}
54
+ func Status (client pb.RuntimeServiceClient , verbose bool ) error {
55
+ request := & pb.StatusRequest {Verbose : verbose }
48
56
logrus .Debugf ("StatusRequest: %v" , request )
49
57
r , err := client .Status (context .Background (), request )
50
58
logrus .Debugf ("StatusResponse: %v" , r )
@@ -57,6 +65,20 @@ func Status(client pb.RuntimeServiceClient) error {
57
65
for _ , c := range r .GetStatus ().GetConditions () {
58
66
fmt .Fprintf (w , "%s\t %v\t %s\t %s\n " , c .Type , c .Status , c .Reason , c .Message )
59
67
}
68
+ if verbose {
69
+ fmt .Fprintln (w , "Extra Info: " )
70
+ for key , value := range r .Info {
71
+ var buf * bytes.Buffer
72
+ err := json .Indent (buf , []byte (value ), "" , " " )
73
+ if err != nil {
74
+ return err
75
+ }
76
+
77
+ fmt .Fprintf (w , " %s: " , key )
78
+ fmt .Fprintf (w , string (buf .Bytes ()))
79
+ }
80
+ }
60
81
w .Flush ()
82
+
61
83
return nil
62
84
}
0 commit comments