@@ -179,6 +179,9 @@ func getCreateContainerTestData() (*runtime.ContainerConfig, *runtime.PodSandbox
179179
180180 assert .Contains (t , spec .Annotations , annotations .SandboxName )
181181 assert .EqualValues (t , spec .Annotations [annotations .SandboxName ], "test-sandbox-name" )
182+
183+ assert .Contains (t , spec .Annotations , annotations .ImageName )
184+ assert .EqualValues (t , spec .Annotations [annotations .ImageName ], testImageName )
182185 }
183186 return config , sandboxConfig , imageConfig , specCheck
184187}
@@ -236,7 +239,7 @@ func TestContainerCapabilities(t *testing.T) {
236239 c := newTestCRIService ()
237240
238241 containerConfig .Linux .SecurityContext .Capabilities = test .capability
239- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
242+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
240243 require .NoError (t , err )
241244
242245 if selinux .GetEnabled () {
@@ -271,7 +274,7 @@ func TestContainerSpecTty(t *testing.T) {
271274 c := newTestCRIService ()
272275 for _ , tty := range []bool {true , false } {
273276 containerConfig .Tty = tty
274- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
277+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
275278 require .NoError (t , err )
276279 specCheck (t , testID , testSandboxID , testPid , spec )
277280 assert .Equal (t , tty , spec .Process .Terminal )
@@ -298,7 +301,7 @@ func TestContainerSpecDefaultPath(t *testing.T) {
298301 imageConfig .Env = append (imageConfig .Env , pathenv )
299302 expected = pathenv
300303 }
301- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
304+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
302305 require .NoError (t , err )
303306 specCheck (t , testID , testSandboxID , testPid , spec )
304307 assert .Contains (t , spec .Process .Env , expected )
@@ -315,7 +318,7 @@ func TestContainerSpecReadonlyRootfs(t *testing.T) {
315318 c := newTestCRIService ()
316319 for _ , readonly := range []bool {true , false } {
317320 containerConfig .Linux .SecurityContext .ReadonlyRootfs = readonly
318- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
321+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
319322 require .NoError (t , err )
320323 specCheck (t , testID , testSandboxID , testPid , spec )
321324 assert .Equal (t , readonly , spec .Root .Readonly )
@@ -354,7 +357,7 @@ func TestContainerSpecWithExtraMounts(t *testing.T) {
354357 Readonly : false ,
355358 },
356359 }
357- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , extraMounts , ociRuntime )
360+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , extraMounts , ociRuntime )
358361 require .NoError (t , err )
359362 specCheck (t , testID , testSandboxID , testPid , spec )
360363 var mounts , sysMounts , devMounts []runtimespec.Mount
@@ -422,7 +425,7 @@ func TestContainerAndSandboxPrivileged(t *testing.T) {
422425 sandboxConfig .Linux .SecurityContext = & runtime.LinuxSandboxSecurityContext {
423426 Privileged : test .sandboxPrivileged ,
424427 }
425- _ , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
428+ _ , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
426429 if test .expectError {
427430 assert .Error (t , err )
428431 } else {
@@ -613,7 +616,7 @@ func TestPrivilegedBindMount(t *testing.T) {
613616 containerConfig .Linux .SecurityContext .Privileged = test .privileged
614617 sandboxConfig .Linux .SecurityContext .Privileged = test .privileged
615618
616- spec , err := c .containerSpec (t .Name (), testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
619+ spec , err := c .containerSpec (t .Name (), testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
617620
618621 assert .NoError (t , err )
619622 if test .expectedSysFSRO {
@@ -770,7 +773,7 @@ func TestPidNamespace(t *testing.T) {
770773 } {
771774 t .Logf ("TestCase %q" , desc )
772775 containerConfig .Linux .SecurityContext .NamespaceOptions = & runtime.NamespaceOption {Pid : test .pidNS }
773- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
776+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
774777 require .NoError (t , err )
775778 assert .Contains (t , spec .Linux .Namespaces , test .expected )
776779 }
@@ -785,7 +788,7 @@ func TestNoDefaultRunMount(t *testing.T) {
785788 ociRuntime := config.Runtime {}
786789 c := newTestCRIService ()
787790
788- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
791+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
789792 assert .NoError (t , err )
790793 for _ , mount := range spec .Mounts {
791794 assert .NotEqual (t , "/run" , mount .Destination )
@@ -1158,7 +1161,7 @@ func TestMaskedAndReadonlyPaths(t *testing.T) {
11581161 sandboxConfig .Linux .SecurityContext = & runtime.LinuxSandboxSecurityContext {
11591162 Privileged : test .privileged ,
11601163 }
1161- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
1164+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
11621165 require .NoError (t , err )
11631166 if ! test .privileged { // specCheck presumes an unprivileged container
11641167 specCheck (t , testID , testSandboxID , testPid , spec )
@@ -1205,7 +1208,7 @@ func TestHostname(t *testing.T) {
12051208 sandboxConfig .Linux .SecurityContext = & runtime.LinuxSandboxSecurityContext {
12061209 NamespaceOptions : & runtime.NamespaceOption {Network : test .networkNs },
12071210 }
1208- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
1211+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
12091212 require .NoError (t , err )
12101213 specCheck (t , testID , testSandboxID , testPid , spec )
12111214 assert .Contains (t , spec .Process .Env , test .expectedEnv )
@@ -1217,7 +1220,7 @@ func TestDisableCgroup(t *testing.T) {
12171220 ociRuntime := config.Runtime {}
12181221 c := newTestCRIService ()
12191222 c .config .DisableCgroup = true
1220- spec , err := c .containerSpec ("test-id" , "sandbox-id" , 1234 , "" , "container-name" , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
1223+ spec , err := c .containerSpec ("test-id" , "sandbox-id" , 1234 , "" , "container-name" , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
12211224 require .NoError (t , err )
12221225
12231226 t .Log ("resource limit should not be set" )
@@ -1340,7 +1343,7 @@ func TestPrivilegedDevices(t *testing.T) {
13401343 ociRuntime := config.Runtime {
13411344 PrivilegedWithoutHostDevices : test .privilegedWithoutHostDevices ,
13421345 }
1343- spec , err := c .containerSpec (t .Name (), testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
1346+ spec , err := c .containerSpec (t .Name (), testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
13441347 assert .NoError (t , err )
13451348
13461349 hostDevicesRaw , err := devices .HostDevices ()
@@ -1389,7 +1392,7 @@ func TestBaseOCISpec(t *testing.T) {
13891392 testPid := uint32 (1234 )
13901393 containerConfig , sandboxConfig , imageConfig , specCheck := getCreateContainerTestData ()
13911394
1392- spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
1395+ spec , err := c .containerSpec (testID , testSandboxID , testPid , "" , testContainerName , testImageName , containerConfig , sandboxConfig , imageConfig , nil , ociRuntime )
13931396 assert .NoError (t , err )
13941397
13951398 specCheck (t , testID , testSandboxID , testPid , spec )
0 commit comments