@@ -113,11 +113,20 @@ def build_images(shared_tmpdir, build_container, request, force_aws_upload):
113113 password = "password"
114114 kargs = "systemd.journald.forward_to_console=1"
115115
116+ default_ip = testutil .get_ip_from_default_route ()
117+
118+ gpg_config = testutil .GPGConfig ()
119+ registry_config = testutil .RegistryConfig (local_registry = f"{ default_ip } :5000" )
120+ container_ref = tc .container_ref
121+
122+ if tc .sign :
123+ container_ref = testutil .sign_container_image (gpg_config , registry_config , container_ref )
124+
116125 # params can be long and the qmp socket (that has a limit of 100ish
117126 # AF_UNIX) is derived from the path
118127 # hash the container_ref+target_arch, but exclude the image_type so that the output path is shared between calls to
119128 # different image type combinations
120- output_path = shared_tmpdir / format (abs (hash (tc . container_ref + str (tc .target_arch ))), "x" )
129+ output_path = shared_tmpdir / format (abs (hash (container_ref + str (tc .target_arch ))), "x" )
121130 output_path .mkdir (exist_ok = True )
122131
123132 # make sure that the test store exists, because podman refuses to start if the source directory for a volume
@@ -164,7 +173,7 @@ def build_images(shared_tmpdir, build_container, request, force_aws_upload):
164173 bib_output = bib_output_path .read_text (encoding = "utf8" )
165174 results .append (ImageBuildResult (
166175 image_type , generated_img , tc .target_arch , tc .osinfo_template ,
167- tc . container_ref , tc .rootfs , username , password ,
176+ container_ref , tc .rootfs , username , password ,
168177 ssh_keyfile_private_path , kargs , bib_output , journal_output ))
169178
170179 # generate new keyfile
@@ -257,15 +266,28 @@ def build_images(shared_tmpdir, build_container, request, force_aws_upload):
257266 if tc .local :
258267 cmd .extend (["-v" , "/var/lib/containers/storage:/var/lib/containers/storage" ])
259268
269+ if tc .sign :
270+ lookaside_config = registry_config .lookaside_config
271+ gpg_pub_key = gpg_config .pub_key
272+ sigstore_dir = registry_config .sigstore_dir
273+ signed_image_args = [
274+ "-v" , "/etc/containers/policy.json:/etc/containers/policy.json" ,
275+ "-v" , f"{ gpg_pub_key } :{ gpg_pub_key } " ,
276+ "-v" , f"{ lookaside_config } :{ lookaside_config } " ,
277+ "-v" , f"{ sigstore_dir } :{ sigstore_dir } " ,
278+ ]
279+ cmd .extend (signed_image_args )
280+
260281 cmd .extend ([
261282 * creds_args ,
262283 build_container ,
263- tc . container_ref ,
284+ container_ref ,
264285 * types_arg ,
265286 * upload_args ,
266287 * target_arch_args ,
267288 * tc .bib_rootfs_args (),
268289 "--local" if tc .local else "--local=false" ,
290+ "--tls-verify=false" if tc .sign else "--tls-verify=true"
269291 ])
270292
271293 # print the build command for easier tracing
@@ -299,7 +321,7 @@ def del_ami():
299321 for image_type in image_types :
300322 results .append (ImageBuildResult (
301323 image_type , artifact [image_type ], tc .target_arch , tc .osinfo_template ,
302- tc . container_ref , tc .rootfs , username , password ,
324+ container_ref , tc .rootfs , username , password ,
303325 ssh_keyfile_private_path , kargs , bib_output , journal_output , metadata ))
304326 yield results
305327
@@ -316,7 +338,7 @@ def del_ami():
316338 img .unlink ()
317339 else :
318340 print ("does not exist" )
319- subprocess .run (["podman" , "rmi" , tc . container_ref ], check = False )
341+ subprocess .run (["podman" , "rmi" , container_ref ], check = False )
320342 return
321343
322344
0 commit comments