@@ -180,6 +180,9 @@ func getCreateContainerTestData() (*runtime.ContainerConfig, *runtime.PodSandbox
180180
181181 assert .Contains (t , spec .Annotations , annotations .SandboxName )
182182 assert .EqualValues (t , spec .Annotations [annotations .SandboxName ], "test-sandbox-name" )
183+
184+ assert .Contains (t , spec .Annotations , annotations .ImageName )
185+ assert .EqualValues (t , spec .Annotations [annotations .ImageName ], testImageName )
183186 }
184187 return config , sandboxConfig , imageConfig , specCheck
185188}
@@ -237,7 +240,7 @@ func TestContainerCapabilities(t *testing.T) {
237240 c := newTestCRIService ()
238241
239242 containerConfig .Linux .SecurityContext .Capabilities = test .capability
240- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
243+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
241244 require .NoError (t , err )
242245
243246 if selinux .GetEnabled () {
@@ -272,7 +275,7 @@ func TestContainerSpecTty(t *testing.T) {
272275 c := newTestCRIService ()
273276 for _ , tty := range []bool {true , false } {
274277 containerConfig .Tty = tty
275- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
278+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
276279 require .NoError (t , err )
277280 specCheck (t , testID , testSandboxID , testPid , spec )
278281 assert .Equal (t , tty , spec .Process .Terminal )
@@ -299,7 +302,7 @@ func TestContainerSpecDefaultPath(t *testing.T) {
299302 imageConfig .Env = append (imageConfig .Env , pathenv )
300303 expected = pathenv
301304 }
302- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
305+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
303306 require .NoError (t , err )
304307 specCheck (t , testID , testSandboxID , testPid , spec )
305308 assert .Contains (t , spec .Process .Env , expected )
@@ -316,7 +319,7 @@ func TestContainerSpecReadonlyRootfs(t *testing.T) {
316319 c := newTestCRIService ()
317320 for _ , readonly := range []bool {true , false } {
318321 containerConfig .Linux .SecurityContext .ReadonlyRootfs = readonly
319- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
322+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
320323 require .NoError (t , err )
321324 specCheck (t , testID , testSandboxID , testPid , spec )
322325 assert .Equal (t , readonly , spec .Root .Readonly )
@@ -355,7 +358,7 @@ func TestContainerSpecWithExtraMounts(t *testing.T) {
355358 Readonly : false ,
356359 },
357360 }
358- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , extraMounts , ociRuntime )
361+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , extraMounts , ociRuntime )
359362 require .NoError (t , err )
360363 specCheck (t , testID , testSandboxID , testPid , spec )
361364 var mounts , sysMounts , devMounts []runtimespec.Mount
@@ -423,7 +426,7 @@ func TestContainerAndSandboxPrivileged(t *testing.T) {
423426 sandboxConfig .Linux .SecurityContext = & runtime.LinuxSandboxSecurityContext {
424427 Privileged : test .sandboxPrivileged ,
425428 }
426- _ , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
429+ _ , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
427430 if test .expectError {
428431 assert .Error (t , err )
429432 } else {
@@ -614,7 +617,7 @@ func TestPrivilegedBindMount(t *testing.T) {
614617 containerConfig .Linux .SecurityContext .Privileged = test .privileged
615618 sandboxConfig .Linux .SecurityContext .Privileged = test .privileged
616619
617- spec , err := c .containerSpec (t .Name (), testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
620+ spec , err := c .containerSpec (t .Name (), testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
618621
619622 assert .NoError (t , err )
620623 if test .expectedSysFSRO {
@@ -771,7 +774,7 @@ func TestPidNamespace(t *testing.T) {
771774 } {
772775 t .Logf ("TestCase %q" , desc )
773776 containerConfig .Linux .SecurityContext .NamespaceOptions = & runtime.NamespaceOption {Pid : test .pidNS }
774- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
777+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
775778 require .NoError (t , err )
776779 assert .Contains (t , spec .Linux .Namespaces , test .expected )
777780 }
@@ -786,7 +789,7 @@ func TestNoDefaultRunMount(t *testing.T) {
786789 ociRuntime := config.Runtime {}
787790 c := newTestCRIService ()
788791
789- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
792+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
790793 assert .NoError (t , err )
791794 for _ , mount := range spec .Mounts {
792795 assert .NotEqual (t , "/run" , mount .Destination )
@@ -1159,7 +1162,7 @@ func TestMaskedAndReadonlyPaths(t *testing.T) {
11591162 sandboxConfig .Linux .SecurityContext = & runtime.LinuxSandboxSecurityContext {
11601163 Privileged : test .privileged ,
11611164 }
1162- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
1165+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
11631166 require .NoError (t , err )
11641167 if ! test .privileged { // specCheck presumes an unprivileged container
11651168 specCheck (t , testID , testSandboxID , testPid , spec )
@@ -1206,7 +1209,7 @@ func TestHostname(t *testing.T) {
12061209 sandboxConfig .Linux .SecurityContext = & runtime.LinuxSandboxSecurityContext {
12071210 NamespaceOptions : & runtime.NamespaceOption {Network : test .networkNs },
12081211 }
1209- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
1212+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
12101213 require .NoError (t , err )
12111214 specCheck (t , testID , testSandboxID , testPid , spec )
12121215 assert .Contains (t , spec .Process .Env , test .expectedEnv )
@@ -1218,7 +1221,7 @@ func TestDisableCgroup(t *testing.T) {
12181221 ociRuntime := config.Runtime {}
12191222 c := newTestCRIService ()
12201223 c .config .DisableCgroup = true
1221- spec , err := c .containerSpec ("test-id" , "sandbox-id" , 1234 , "" , "container-name" , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
1224+ spec , err := c .containerSpec ("test-id" , "sandbox-id" , 1234 , "" , "container-name" , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
12221225 require .NoError (t , err )
12231226
12241227 t .Log ("resource limit should not be set" )
@@ -1341,7 +1344,7 @@ func TestPrivilegedDevices(t *testing.T) {
13411344 ociRuntime := config.Runtime {
13421345 PrivilegedWithoutHostDevices : test .privilegedWithoutHostDevices ,
13431346 }
1344- spec , err := c .containerSpec (t .Name (), testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
1347+ spec , err := c .containerSpec (t .Name (), testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
13451348 assert .NoError (t , err )
13461349
13471350 hostDevicesRaw , err := devices .HostDevices ()
@@ -1390,7 +1393,7 @@ func TestBaseOCISpec(t *testing.T) {
13901393 testPid := uint32 (1234 )
13911394 containerConfig , sandboxConfig , imageConfig , specCheck := getCreateContainerTestData ()
13921395
1393- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
1396+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
13941397 assert .NoError (t , err )
13951398
13961399 specCheck (t , testID , testSandboxID , testPid , spec )
0 commit comments