#1354 Make fetch_mmd public
Merged 4 years ago by mprahl. Opened 4 years ago by cqi.
cqi/fm-orchestrator make-fetch_mmd-public  into  master

@@ -655,20 +655,6 @@ 

      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 @@ 

              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 @@ 

          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 @@ 

      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 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,

-     submit_module_build_from_scm,

-     submit_module_build_from_yaml,

+     filter_module_builds,

      get_scm_url_re,

-     cors_header,

-     validate_api_version,

      import_mmd,

-     get_mmd_from_scm,

+     pagination_metadata,

      str_to_bool,

+     submit_module_build_from_scm,

+     submit_module_build_from_yaml,

+     validate_api_version,

  )

  from module_build_service.errors import ValidationError, Forbidden, NotFound, ProgrammingError

  from module_build_service.backports import jsonify
@@ -296,7 +296,7 @@ 

          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),

fetch_mmd was imported at other places like in views.py for
ImportModuleAPI. So, make it public.

Signed-off-by: Chenxiong Qi cqi@redhat.com

Commit efb0ab3 fixes this pull-request

Pull-Request has been merged by mprahl

4 years ago

Pull-Request has been merged by mprahl

4 years ago