mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-10 00:25:00 +08:00
Add get_module_repo function with only Copr implementation
This commit is contained in:
@@ -32,7 +32,7 @@ from module_build_service import app, conf, db
|
||||
from module_build_service.config import Config
|
||||
from module_build_service.pdc import (
|
||||
get_pdc_client_session, get_module, get_module_runtime_dependencies,
|
||||
get_module_tag, get_module_build_dependencies)
|
||||
get_module_tag, get_module_build_dependencies, get_module_repo)
|
||||
import module_build_service.auth
|
||||
|
||||
|
||||
@@ -86,6 +86,10 @@ def testpdc():
|
||||
print ("build_deps=%s" % get_module_build_dependencies(
|
||||
pdc_session, module))
|
||||
print ("tag=%s" % get_module_tag(pdc_session, module))
|
||||
|
||||
module2 = get_module(pdc_session, {"name": "coprtestmodule", "version": "4.3.43", "release": 1})
|
||||
print ("pdc_data=%s" % str(module))
|
||||
print ("repo=%s" % get_module_repo(pdc_session, module2))
|
||||
else:
|
||||
print ('module was not found')
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
import modulemd
|
||||
from pdc_client import PDCClient
|
||||
import six
|
||||
import os
|
||||
|
||||
|
||||
|
||||
@@ -153,6 +154,36 @@ def get_module_tag(session, module_info, strict=False):
|
||||
"""
|
||||
return get_module(session, module_info, strict=strict)['koji_tag']
|
||||
|
||||
def get_module_repo(session, module_info, strict=False):
|
||||
"""
|
||||
:param session : PDCClient instance
|
||||
:param module_info: list of module_info dicts
|
||||
:param strict: Normally this function returns None if no module can be
|
||||
found. If strict=True, then a ValueError is raised.
|
||||
:return: URL to a DNF repository for the module
|
||||
"""
|
||||
module = get_module(session, module_info, strict=strict)
|
||||
if not module:
|
||||
return None
|
||||
|
||||
# Module was built in Koji
|
||||
# @TODO There should be implemented retrieveing URL to a module repofile in koji
|
||||
if module["koji_tag"] != "-":
|
||||
raise NotImplementedError
|
||||
|
||||
# Module was built in Copr
|
||||
# @TODO get the correct user
|
||||
owner, project = "@copr", module["variant_id"]
|
||||
|
||||
# Some user/group logic. We should really be using python-copr for that
|
||||
g = ""
|
||||
if owner[0] == "@":
|
||||
g = "/g"
|
||||
owner = owner[1:]
|
||||
|
||||
base = "http://copr-fe-dev.cloud.fedoraproject.org"
|
||||
return "{}/coprs{}/{}/{}/repo/modules".format(base, g, owner, project)
|
||||
|
||||
def module_depsolving_wrapper(session, module_list, strict=True):
|
||||
"""
|
||||
:param session : PDCClient instance
|
||||
|
||||
Reference in New Issue
Block a user