@@ -90,6 +90,16 @@ var pullImageCommand = &cli.Command{
90
90
Usage : "Maximum time to be used for pulling the image, disabled if set to 0s" ,
91
91
EnvVars : []string {"CRICTL_PULL_TIMEOUT" },
92
92
},
93
+ & cli.BoolFlag {
94
+ Name : "mount" ,
95
+ Aliases : []string {"m" },
96
+ Usage : "Mount the OCI object" ,
97
+ },
98
+ & cli.StringFlag {
99
+ Name : "mount-label" ,
100
+ Aliases : []string {"l" },
101
+ Usage : "Mount label for the OCI object" ,
102
+ },
93
103
},
94
104
ArgsUsage : "NAME[:TAG|@DIGEST]" ,
95
105
Action : func (c * cli.Context ) error {
@@ -127,11 +137,15 @@ var pullImageCommand = &cli.Command{
127
137
}
128
138
}
129
139
timeout := c .Duration ("pull-timeout" )
130
- r , err := PullImageWithSandbox (imageClient , imageName , auth , sandbox , ann , timeout )
140
+ r , err := PullImageWithSandbox (imageClient , imageName , auth , sandbox , ann , timeout , c . Bool ( "mount" ), c . String ( "mount-label" ) )
131
141
if err != nil {
132
142
return fmt .Errorf ("pulling image: %w" , err )
133
143
}
134
144
fmt .Printf ("Image is up to date for %s\n " , r .ImageRef )
145
+
146
+ if r .Mountpoint != "" {
147
+ fmt .Printf ("Image mounted to: %s\n " , r .Mountpoint )
148
+ }
135
149
return nil
136
150
},
137
151
}
@@ -417,7 +431,9 @@ var removeImageCommand = &cli.Command{
417
431
}
418
432
419
433
// Container images
420
- containers , err := runtimeClient .ListContainers (context .TODO (), nil )
434
+ containers , err := InterruptableRPC (nil , func (ctx context.Context ) ([]* pb.Container , error ) {
435
+ return runtimeClient .ListContainers (ctx , nil )
436
+ })
421
437
if err != nil {
422
438
return err
423
439
}
@@ -641,11 +657,13 @@ func normalizeRepoDigest(repoDigests []string) (string, string) {
641
657
642
658
// PullImageWithSandbox sends a PullImageRequest to the server, and parses
643
659
// the returned PullImageResponse.
644
- func PullImageWithSandbox (client internalapi.ImageManagerService , image string , auth * pb.AuthConfig , sandbox * pb.PodSandboxConfig , ann map [string ]string , timeout time.Duration ) (* pb.PullImageResponse , error ) {
660
+ func PullImageWithSandbox (client internalapi.ImageManagerService , image string , auth * pb.AuthConfig , sandbox * pb.PodSandboxConfig , ann map [string ]string , timeout time.Duration , mount bool , mountLabel string ) (* pb.PullImageResponse , error ) {
645
661
request := & pb.PullImageRequest {
646
662
Image : & pb.ImageSpec {
647
663
Image : image ,
648
664
Annotations : ann ,
665
+ Mount : mount ,
666
+ MountLabel : mountLabel ,
649
667
},
650
668
}
651
669
if auth != nil {
@@ -669,11 +687,12 @@ func PullImageWithSandbox(client internalapi.ImageManagerService, image string,
669
687
defer cancel ()
670
688
}
671
689
672
- res , err := client .PullImage (ctx , request .Image , request .Auth , request .SandboxConfig )
690
+ resp , err := InterruptableRPC (ctx , func (ctx context.Context ) (* pb.PullImageResponse , error ) {
691
+ return client .PullImageFullResponse (ctx , request .Image , request .Auth , request .SandboxConfig )
692
+ })
673
693
if err != nil {
674
694
return nil , err
675
695
}
676
- resp := & pb.PullImageResponse {ImageRef : res }
677
696
logrus .Debugf ("PullImageResponse: %v" , resp )
678
697
return resp , nil
679
698
}
@@ -683,7 +702,9 @@ func PullImageWithSandbox(client internalapi.ImageManagerService, image string,
683
702
func ListImages (client internalapi.ImageManagerService , image string ) (* pb.ListImagesResponse , error ) {
684
703
request := & pb.ListImagesRequest {Filter : & pb.ImageFilter {Image : & pb.ImageSpec {Image : image }}}
685
704
logrus .Debugf ("ListImagesRequest: %v" , request )
686
- res , err := client .ListImages (context .TODO (), request .Filter )
705
+ res , err := InterruptableRPC (nil , func (ctx context.Context ) ([]* pb.Image , error ) {
706
+ return client .ListImages (ctx , request .Filter )
707
+ })
687
708
if err != nil {
688
709
return nil , err
689
710
}
@@ -790,7 +811,9 @@ func ImageStatus(client internalapi.ImageManagerService, image string, verbose b
790
811
Verbose : verbose ,
791
812
}
792
813
logrus .Debugf ("ImageStatusRequest: %v" , request )
793
- res , err := client .ImageStatus (context .TODO (), request .Image , request .Verbose )
814
+ res , err := InterruptableRPC (nil , func (ctx context.Context ) (* pb.ImageStatusResponse , error ) {
815
+ return client .ImageStatus (ctx , request .Image , request .Verbose )
816
+ })
794
817
if err != nil {
795
818
return nil , err
796
819
}
@@ -806,16 +829,18 @@ func RemoveImage(client internalapi.ImageManagerService, image string) error {
806
829
}
807
830
request := & pb.RemoveImageRequest {Image : & pb.ImageSpec {Image : image }}
808
831
logrus .Debugf ("RemoveImageRequest: %v" , request )
809
- if err := client . RemoveImage ( context .TODO (), request . Image ); err != nil {
810
- return err
811
- }
812
- return nil
832
+ _ , err := InterruptableRPC ( nil , func ( ctx context.Context ) ( * pb. RemoveImageResponse , error ) {
833
+ return nil , client . RemoveImage ( ctx , request . Image )
834
+ })
835
+ return err
813
836
}
814
837
815
838
// ImageFsInfo sends an ImageStatusRequest to the server, and parses
816
839
// the returned ImageFsInfoResponse.
817
840
func ImageFsInfo (client internalapi.ImageManagerService ) (* pb.ImageFsInfoResponse , error ) {
818
- res , err := client .ImageFsInfo (context .TODO ())
841
+ res , err := InterruptableRPC (nil , func (ctx context.Context ) (* pb.ImageFsInfoResponse , error ) {
842
+ return client .ImageFsInfo (ctx )
843
+ })
819
844
if err != nil {
820
845
return nil , err
821
846
}
0 commit comments