@@ -313,6 +313,58 @@ var removeImageCommand = cli.Command{
313
313
},
314
314
}
315
315
316
+ var imageFsInfoCommand = cli.Command {
317
+ Name : "imagefsinfo" ,
318
+ Usage : "Return image filesystem info" ,
319
+ SkipArgReorder : true ,
320
+ UseShortOptionHandling : true ,
321
+ Flags : []cli.Flag {
322
+ cli.StringFlag {
323
+ Name : "output, o" ,
324
+ Usage : "Output format, One of: json|yaml|table" ,
325
+ },
326
+ },
327
+ Action : func (context * cli.Context ) error {
328
+ if err := getImageClient (context ); err != nil {
329
+ return err
330
+ }
331
+ output := context .String ("output" )
332
+ if output == "" { // default to json output
333
+ output = "json"
334
+ }
335
+
336
+ r , err := ImageFsInfo (imageClient )
337
+ if err != nil {
338
+ return fmt .Errorf ("image filesystem info request failed: %v" , err )
339
+ }
340
+ for _ , info := range r .ImageFilesystems {
341
+ status , err := protobufObjectToJSON (info )
342
+ if err != nil {
343
+ return fmt .Errorf ("failed to marshal image filesystem info to json: %v" , err )
344
+ }
345
+
346
+ switch output {
347
+ case "json" , "yaml" :
348
+ if err := outputStatusInfo (status , nil , output ); err != nil {
349
+ return fmt .Errorf ("failed to output image filesystem info %v" , err )
350
+ }
351
+ continue
352
+ case "table" : // table output is after this switch block
353
+ default :
354
+ return fmt .Errorf ("output option cannot be %s" , output )
355
+ }
356
+
357
+ // otherwise output in table format
358
+ fmt .Printf ("TimeStamp: %d\n " , info .Timestamp )
359
+ fmt .Printf ("UsedBytes: %s\n " , info .UsedBytes )
360
+ fmt .Printf ("Mountpoint: %s\n " , info .FsId .Mountpoint )
361
+ }
362
+
363
+ return nil
364
+
365
+ },
366
+ }
367
+
316
368
func parseCreds (creds string ) (string , string , error ) {
317
369
if creds == "" {
318
370
return "" , "" , errors .New ("credentials can't be empty" )
@@ -439,3 +491,13 @@ func RemoveImage(client pb.ImageServiceClient, image string) (resp *pb.RemoveIma
439
491
logrus .Debugf ("RemoveImageResponse: %v" , resp )
440
492
return
441
493
}
494
+
495
+ // ImageFsInfo sends an ImageStatusRequest to the server, and parses
496
+ // the returned ImageFsInfoResponse.
497
+ func ImageFsInfo (client pb.ImageServiceClient ) (resp * pb.ImageFsInfoResponse , err error ) {
498
+ request := & pb.ImageFsInfoRequest {}
499
+ logrus .Debugf ("ImageFsInfoRequest: %v" , request )
500
+ resp , err = client .ImageFsInfo (context .Background (), request )
501
+ logrus .Debugf ("ImageFsInfoResponse: %v" , resp )
502
+ return
503
+ }
0 commit comments