fus: Strip protocol from repo path
Only local paths are supported currently. As such, `file://` can be stripped, and for anything else we should raise an exception. JIRA: COMPOSE-2996 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
37c89dfde6
commit
4537001ff6
@ -37,9 +37,9 @@ def get_cmd(
|
|||||||
cmd = ["fus", "--verbose", "--arch", arch]
|
cmd = ["fus", "--verbose", "--arch", arch]
|
||||||
|
|
||||||
for idx, repo in enumerate(repos):
|
for idx, repo in enumerate(repos):
|
||||||
cmd.append("--repo=repo-%s,repo,%s" % (idx, repo))
|
cmd.append("--repo=repo-%s,repo,%s" % (idx, _prep_path(repo)))
|
||||||
for idx, repo in enumerate(lookasides):
|
for idx, repo in enumerate(lookasides):
|
||||||
cmd.append("--repo=lookaside-%s,lookaside,%s" % (idx, repo))
|
cmd.append("--repo=lookaside-%s,lookaside,%s" % (idx, _prep_path(repo)))
|
||||||
|
|
||||||
if platform:
|
if platform:
|
||||||
cmd.append("--platform=%s" % platform)
|
cmd.append("--platform=%s" % platform)
|
||||||
@ -52,6 +52,17 @@ def get_cmd(
|
|||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
|
def _prep_path(path):
|
||||||
|
"""Strip file:// from the path if present or raise exception for other
|
||||||
|
protocols.
|
||||||
|
"""
|
||||||
|
if "://" in path:
|
||||||
|
proto, path = path.split("://", 2)
|
||||||
|
if proto != "file":
|
||||||
|
raise ValueError("Only repositories on local filesystem are supported.")
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
def parse_output(output):
|
def parse_output(output):
|
||||||
"""Read output of fus from the given filepath, and return a set of tuples
|
"""Read output of fus from the given filepath, and return a set of tuples
|
||||||
(NVR, arch, flags) and a set of module NSVCs.
|
(NVR, arch, flags) and a set of module NSVCs.
|
||||||
|
@ -47,6 +47,27 @@ class TestGetCmd(unittest.TestCase):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_strip_file_protocol(self):
|
||||||
|
cmd = fus.get_cmd("x86_64", ["file:///tmp"], [], [], [], [])
|
||||||
|
self.assertEqual(
|
||||||
|
cmd, ["fus", "--verbose", "--arch", "x86_64", "--repo=repo-0,repo,/tmp"]
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_fail_on_http_repo(self):
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
fus.get_cmd("x86_64", ["http:///tmp"], [], [], [], [])
|
||||||
|
|
||||||
|
def test_strip_file_protocol_lookaside(self):
|
||||||
|
cmd = fus.get_cmd("x86_64", [], ["file:///r"], [], [], [])
|
||||||
|
self.assertEqual(
|
||||||
|
cmd,
|
||||||
|
["fus", "--verbose", "--arch", "x86_64", "--repo=lookaside-0,lookaside,/r"]
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_fail_on_http_repo_lookaside(self):
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
fus.get_cmd("x86_64", [], ["http:///tmp"], [], [], [])
|
||||||
|
|
||||||
|
|
||||||
class TestParseOutput(unittest.TestCase):
|
class TestParseOutput(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user