mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-04 19:28:49 +08:00
Allow file:// URLs when building modules locally
This commit is contained in:
@@ -201,7 +201,7 @@ def build_module_locally(url):
|
||||
_insert_fake_baseruntime()
|
||||
|
||||
username = getpass.getuser()
|
||||
submit_module_build(username, url)
|
||||
submit_module_build(username, url, allow_local_url=True)
|
||||
|
||||
msgs = []
|
||||
msgs.append(RidaModule("local module build", 2, 1))
|
||||
|
||||
@@ -47,10 +47,10 @@ class SCM(object):
|
||||
# Assuming git for HTTP schemas
|
||||
types = {
|
||||
"git": ("git://", "git+http://", "git+https://",
|
||||
"git+rsync://", "http://", "https://")
|
||||
"git+rsync://", "http://", "https://", "file://")
|
||||
}
|
||||
|
||||
def __init__(self, url, allowed_scm=None):
|
||||
def __init__(self, url, allowed_scm=None, allow_local = False):
|
||||
"""Initialize the SCM object using the specified scmurl.
|
||||
|
||||
If url is not in the list of allowed_scm, an error will be raised.
|
||||
@@ -61,6 +61,7 @@ class SCM(object):
|
||||
git+rsync://
|
||||
http://
|
||||
https://
|
||||
file://
|
||||
|
||||
:param str url: The unmodified scmurl
|
||||
:param list allowed_scm: The list of allowed SCMs, optional
|
||||
@@ -69,7 +70,8 @@ class SCM(object):
|
||||
|
||||
if allowed_scm:
|
||||
for allowed in allowed_scm:
|
||||
if url.startswith(allowed):
|
||||
if (url.startswith(allowed)
|
||||
or (allow_local and url.startswith("file://"))):
|
||||
break
|
||||
else:
|
||||
raise Unauthorized(
|
||||
|
||||
@@ -208,7 +208,7 @@ def filter_module_builds(flask_request):
|
||||
return query.paginate(page, per_page, False)
|
||||
|
||||
|
||||
def _fetch_mmd(url):
|
||||
def _fetch_mmd(url, allow_local_url = False):
|
||||
# Import it here, because SCM uses utils methods
|
||||
# and fails to import them because of dep-chain.
|
||||
import module_build_service.scm
|
||||
@@ -219,7 +219,7 @@ def _fetch_mmd(url):
|
||||
try:
|
||||
log.debug('Verifying modulemd')
|
||||
td = tempfile.mkdtemp()
|
||||
scm = module_build_service.scm.SCM(url, conf.scmurls)
|
||||
scm = module_build_service.scm.SCM(url, conf.scmurls, allow_local_url)
|
||||
cod = scm.checkout(td)
|
||||
cofn = os.path.join(cod, (scm.name + ".yaml"))
|
||||
|
||||
@@ -343,12 +343,12 @@ def record_component_builds(mmd, module, initial_batch = 1):
|
||||
|
||||
return batch
|
||||
|
||||
def submit_module_build(username, url):
|
||||
def submit_module_build(username, url, allow_local_url = False):
|
||||
# Import it here, because SCM uses utils methods
|
||||
# and fails to import them because of dep-chain.
|
||||
import module_build_service.scm
|
||||
|
||||
mmd, scm, yaml = _fetch_mmd(url)
|
||||
mmd, scm, yaml = _fetch_mmd(url, allow_local_url)
|
||||
|
||||
# If undefined, set the name field to VCS repo name.
|
||||
if not mmd.name and scm:
|
||||
|
||||
@@ -123,7 +123,7 @@ class ModuleBuildAPI(MethodView):
|
||||
log.error("The submitted scmurl %r is not valid" % url)
|
||||
raise Unauthorized("The submitted scmurl %s is not valid" % url)
|
||||
|
||||
module = submit_module_build(username, url)
|
||||
module = submit_module_build(username, url, allow_local_url=False)
|
||||
return jsonify(module.json()), 201
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user