Download extra files from container registry

This could be useful for handling flatpak applications in the installer.

All of the specified containers are downloaded into a single oci
layout.

JIRA: RHELCMP-14302
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2024-10-24 17:10:16 +02:00
parent 7d8f3b4b9b
commit 3d5348a672
5 changed files with 130 additions and 11 deletions

View file

@ -223,7 +223,7 @@ class TestCopyFiles(helpers.PungiTestCase):
)
)
def fake_get_file(self, scm_dict, dest, compose):
def fake_get_file(self, scm_dict, dest, compose, arch=None):
self.scm_dict = scm_dict
helpers.touch(os.path.join(dest, scm_dict["file"]))
return [scm_dict["file"]]

View file

@ -799,3 +799,72 @@ class KojiSCMTestCase(SCMBaseTest):
dl.call_args_list,
[mock.call("http://koji.local/koji/images/abc.tar", mock.ANY)],
)
IMAGE_URL = "example.com/image"
class ContainerImageScmWrapperTest(SCMBaseTest):
def test_get_dir_is_not_implemented(self):
with self.assertRaises(RuntimeError):
scm.get_dir_from_scm(
{"scm": "container-image", "repo": IMAGE_URL, "dir": ""}, self.destdir
)
@parameterized.expand(
[
("x86_64", "amd64"),
("aarch64", "arm64"),
("s390x", "s390x"),
]
)
@mock.patch("pungi.wrappers.scm.run")
def test_get_file(self, real_arch, translated_arch, mock_run):
scm.get_file_from_scm(
{
"scm": "container-image",
"repo": IMAGE_URL + ":latest",
"file": "",
"target": "subdir",
},
self.destdir,
arch=real_arch,
)
scm.get_file_from_scm(
{
"scm": "container-image",
"repo": IMAGE_URL + ":prev",
"file": "",
"target": "subdir",
},
self.destdir,
arch=real_arch,
)
self.assertCountEqual(
mock_run.mock_calls,
[
mock.call(
[
"skopeo",
f"--override-arch={translated_arch}",
"copy",
IMAGE_URL + ":latest",
f"oci:{self.destdir}",
"--remove-signatures",
],
can_fail=False,
),
mock.call(
[
"skopeo",
f"--override-arch={translated_arch}",
"copy",
IMAGE_URL + ":prev",
f"oci:{self.destdir}",
"--remove-signatures",
],
can_fail=False,
),
],
)