mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-13 18:15:00 +08:00
Merge #1354 Make fetch_mmd public
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user