diff --git a/manage.py b/manage.py index 49122bb5..77c365b3 100644 --- a/manage.py +++ b/manage.py @@ -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)) diff --git a/module_build_service/scm.py b/module_build_service/scm.py index b7b411af..44570c29 100644 --- a/module_build_service/scm.py +++ b/module_build_service/scm.py @@ -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( diff --git a/module_build_service/utils.py b/module_build_service/utils.py index 0f90a83f..49a108ae 100644 --- a/module_build_service/utils.py +++ b/module_build_service/utils.py @@ -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: diff --git a/module_build_service/views.py b/module_build_service/views.py index 384aa3b9..1160a380 100644 --- a/module_build_service/views.py +++ b/module_build_service/views.py @@ -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