Fix type detection for osbuild images

The image type value passed to the task doesn't match the type as it
will be recorded by Koji.

JIRA: RHELCMP-5727
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2021-08-30 08:40:05 +02:00 committed by lsedlar
parent b7666ba4a4
commit e8ddacd10e

View File

@ -155,7 +155,7 @@ class RunOSBuildThread(WorkerThread):
# architecture, but we don't verify that. # architecture, but we don't verify that.
build_info = koji.koji_proxy.getBuild(build_id) build_info = koji.koji_proxy.getBuild(build_id)
for archive in koji.koji_proxy.listArchives(buildID=build_id): for archive in koji.koji_proxy.listArchives(buildID=build_id):
if archive["type_name"] not in config["image_types"]: if archive["type_name"] not in EXTENSIONS:
# Ignore values that are not of required types. # Ignore values that are not of required types.
continue continue
@ -182,8 +182,11 @@ class RunOSBuildThread(WorkerThread):
linker.link(src_file, image_dest, link_type=compose.conf["link_type"]) linker.link(src_file, image_dest, link_type=compose.conf["link_type"])
suffix = archive["filename"].rsplit(".", 1)[-1] for suffix in EXTENSIONS[archive["type_name"]]:
if suffix not in EXTENSIONS[archive["type_name"]]: if archive["filename"].endswith(suffix):
break
else:
# No suffix matched.
raise RuntimeError( raise RuntimeError(
"Failed to generate metadata. Format %s doesn't match type %s" "Failed to generate metadata. Format %s doesn't match type %s"
% (suffix, archive["type_name"]) % (suffix, archive["type_name"])