From 0d6a26b71ee24c1d19231695cde1d908f6829667 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Fri, 19 Jul 2019 09:28:12 +0800 Subject: [PATCH] Make fetch_mmd public fetch_mmd was imported at other places like in views.py for ImportModuleAPI. So, make it public. Signed-off-by: Chenxiong Qi --- module_build_service/utils/general.py | 14 -------------- module_build_service/utils/submit.py | 6 +++--- module_build_service/views.py | 16 ++++++++-------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/module_build_service/utils/general.py b/module_build_service/utils/general.py index 35ebd4a6..74d4e7c5 100644 --- a/module_build_service/utils/general.py +++ b/module_build_service/utils/general.py @@ -655,20 +655,6 @@ def import_builds_from_local_dnf_repos(db_session, platform_id=None): import_fake_base_module(db_session, "%s:1:000000" % platform_id) -def get_mmd_from_scm(url): - """ - Provided an SCM URL, fetch mmd from the corresponding module YAML - file. If ref is specified within the URL, the mmd will be returned - as of the ref. - """ - from module_build_service.utils.submit import _fetch_mmd - - mmd, _ = _fetch_mmd( - url, branch=None, allow_local_url=False, whitelist_url=False, mandatory_checks=False) - - return mmd - - def get_build_arches(db_session, mmd, config): """ Returns the list of architectures for which the module `mmd` should be built. diff --git a/module_build_service/utils/submit.py b/module_build_service/utils/submit.py index 0b7b3181..83cb4621 100644 --- a/module_build_service/utils/submit.py +++ b/module_build_service/utils/submit.py @@ -487,7 +487,7 @@ def record_component_builds( full_url = component.get_repository() + "?#" + component.get_ref() # It is OK to whitelist all URLs here, because the validity # of every URL have been already checked in format_mmd(...). - included_mmd = _fetch_mmd(full_url, whitelist_url=True)[0] + included_mmd = fetch_mmd(full_url, whitelist_url=True)[0] format_mmd(included_mmd, module.scmurl, module, db_session) batch = record_component_builds( db_session, included_mmd, module, batch, previous_buildorder, main_mmd) @@ -575,7 +575,7 @@ def submit_module_build_from_scm(db_session, username, params, allow_local_url=F log.info("'{}' is not a valid URL, assuming local path".format(url)) url = os.path.abspath(url) url = "file://" + url - mmd, scm = _fetch_mmd(url, branch, allow_local_url) + mmd, scm = fetch_mmd(url, branch, allow_local_url) return submit_module_build(db_session, username, mmd, params) @@ -1065,7 +1065,7 @@ def _is_eol_in_pdc(name, stream): return not results[0]["active"] -def _fetch_mmd(url, branch=None, allow_local_url=False, whitelist_url=False, mandatory_checks=True): +def fetch_mmd(url, branch=None, allow_local_url=False, whitelist_url=False, mandatory_checks=True): # Import it here, because SCM uses utils methods # and fails to import them because of dep-chain. import module_build_service.scm diff --git a/module_build_service/views.py b/module_build_service/views.py index 2c1819d5..09d7a8e6 100644 --- a/module_build_service/views.py +++ b/module_build_service/views.py @@ -35,17 +35,17 @@ from io import BytesIO from module_build_service import app, conf, log, models, db, version, api_version as max_api_version from module_build_service.utils import ( - pagination_metadata, - filter_module_builds, + cors_header, + fetch_mmd, filter_component_builds, + filter_module_builds, + get_scm_url_re, + import_mmd, + pagination_metadata, + str_to_bool, submit_module_build_from_scm, submit_module_build_from_yaml, - get_scm_url_re, - cors_header, validate_api_version, - import_mmd, - get_mmd_from_scm, - str_to_bool, ) from module_build_service.errors import ValidationError, Forbidden, NotFound, ProgrammingError from module_build_service.backports import jsonify @@ -296,7 +296,7 @@ class ImportModuleAPI(MethodView): handler = SCMHandler(request) handler.validate(skip_branch=True, skip_optional_params=True) - mmd = get_mmd_from_scm(handler.data["scmurl"]) + mmd, _ = fetch_mmd(handler.data["scmurl"], mandatory_checks=False) build, messages = import_mmd(db.session, mmd) json_data = { "module": build.json(db.session, show_tasks=False),