File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -892,23 +892,25 @@ func containerNetns(container *mgr.Container) string {
892892
893893// imageToCriImage converts pouch image API to CRI image API.
894894func imageToCriImage (image * apitypes.ImageInfo ) (* runtime.Image , error ) {
895- uid := & runtime.Int64Value {}
896- imageUID , username := getUserFromImageUser (image .Config .User )
897- if imageUID != nil {
898- uid .Value = * imageUID
895+ if image == nil || image .Config == nil {
896+ return nil , fmt .Errorf ("unable to convert a nil pointer to a runtime API image" )
899897 }
900-
901898 size := uint64 (image .Size )
902899 // TODO: improve type ImageInfo to include RepoTags and RepoDigests.
903- return & runtime.Image {
900+ runtimeImage := & runtime.Image {
904901 Id : image .ID ,
905902 RepoTags : image .RepoTags ,
906903 RepoDigests : image .RepoDigests ,
907904 Size_ : size ,
908- Uid : uid ,
909- Username : username ,
910905 Volumes : parseVolumesFromPouch (image .Config .Volumes ),
911- }, nil
906+ }
907+
908+ imageUID , username := getUserFromImageUser (image .Config .User )
909+ if imageUID != nil {
910+ runtimeImage .Uid = & runtime.Int64Value {Value : * imageUID }
911+ }
912+ runtimeImage .Username = username
913+ return runtimeImage , nil
912914}
913915
914916// ensureSandboxImageExists pulls the image when it's not present.
Original file line number Diff line number Diff line change @@ -1182,7 +1182,7 @@ func Test_imageToCriImage(t *testing.T) {
11821182 RepoTags : repoDigests ,
11831183 RepoDigests : repoDigests ,
11841184 Size_ : uint64 (1024 ),
1185- Uid : & runtime. Int64Value {} ,
1185+ Uid : nil ,
11861186 Username : "foo" ,
11871187 Volumes : runtimeVolumes ,
11881188 },
You can’t perform that action at this time.
0 commit comments