@@ -494,28 +494,37 @@ var imageFsInfoCommand = &cli.Command{
494
494
if err != nil {
495
495
return fmt .Errorf ("image filesystem info request: %w" , err )
496
496
}
497
- for _ , info := range r .ImageFilesystems {
498
- status , err := protobufObjectToJSON (info )
499
- if err != nil {
500
- return fmt .Errorf ("marshal image filesystem info to json: %w" , err )
501
- }
497
+ fileSystemReport := func (filesystem []* pb.FilesystemUsage ) error {
498
+ for _ , info := range filesystem {
499
+ status , err := protobufObjectToJSON (info )
500
+ if err != nil {
501
+ return fmt .Errorf ("marshal filesystem info to json: %w" , err )
502
+ }
502
503
503
- switch output {
504
- case "json" , "yaml" , "go-template" :
505
- if err := outputStatusInfo (status , nil , output , tmplStr ); err != nil {
506
- return fmt .Errorf ("output image filesystem info: %w" , err )
504
+ switch output {
505
+ case "json" , "yaml" , "go-template" :
506
+ if err := outputStatusInfo (status , nil , output , tmplStr ); err != nil {
507
+ return fmt .Errorf ("output filesystem info: %w" , err )
508
+ }
509
+ continue
510
+ case "table" : // table output is after this switch block
511
+ default :
512
+ return fmt .Errorf ("output option cannot be %s" , output )
507
513
}
508
- continue
509
- case "table" : // table output is after this switch block
510
- default :
511
- return fmt .Errorf ("output option cannot be %s" , output )
512
- }
513
514
514
- // otherwise output in table format
515
- fmt .Printf ("TimeStamp: %d\n " , info .Timestamp )
516
- fmt .Printf ("Disk: %s\n " , units .HumanSize (float64 (info .UsedBytes .GetValue ())))
517
- fmt .Printf ("Inodes: %d\n " , info .InodesUsed .GetValue ())
518
- fmt .Printf ("Mountpoint: %s\n " , info .FsId .Mountpoint )
515
+ // otherwise output in table format
516
+ fmt .Printf ("TimeStamp: %d\n " , info .Timestamp )
517
+ fmt .Printf ("Disk: %s\n " , units .HumanSize (float64 (info .UsedBytes .GetValue ())))
518
+ fmt .Printf ("Inodes: %d\n " , info .InodesUsed .GetValue ())
519
+ fmt .Printf ("Mountpoint: %s\n " , info .FsId .Mountpoint )
520
+ }
521
+ return nil
522
+ }
523
+ if err := fileSystemReport (r .ImageFilesystems ); err != nil {
524
+ return err
525
+ }
526
+ if err := fileSystemReport (r .ContainerFilesystems ); err != nil {
527
+ return err
519
528
}
520
529
521
530
return nil
0 commit comments