From 5197eb4912e28c3e38b6fb788eac7b7443a86c87 Mon Sep 17 00:00:00 2001 From: mprahl Date: Tue, 7 Aug 2018 12:03:44 -0400 Subject: [PATCH] Revert "Use the libmodulemd API properly when setting values on existing objects" This reverts commit 8173040ea6469cfbbb4a37d569170131366408e9. Since it didn't provide any real benefit after talking with sgallagh, it seems like we'd better off not introduce more risk to the next deployment. --- module_build_service/utils/submit.py | 12 ++++-------- tests/__init__.py | 4 +--- tests/test_utils/test_utils.py | 15 +++++---------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/module_build_service/utils/submit.py b/module_build_service/utils/submit.py index 9ca864e9..be3bcfd5 100644 --- a/module_build_service/utils/submit.py +++ b/module_build_service/utils/submit.py @@ -100,13 +100,11 @@ def format_mmd(mmd, scmurl, session=None): else: xmd['mbs']['commit'] = scm.get_latest() - rpm_components = mmd.get_rpm_components() - module_components = mmd.get_module_components() - if rpm_components or module_components: + if mmd.get_rpm_components() or mmd.get_module_components(): if 'rpms' not in xmd['mbs']: xmd['mbs']['rpms'] = {} # Add missing data in RPM components - for pkgname, pkg in rpm_components.items(): + for pkgname, pkg in mmd.get_rpm_components().items(): if pkg.get_repository() and not conf.rpms_allow_repository: raise Forbidden( "Custom component repositories aren't allowed. " @@ -121,10 +119,9 @@ def format_mmd(mmd, scmurl, session=None): pkg.set_cache(conf.rpms_default_cache + pkgname) if not pkg.get_ref(): pkg.set_ref('master') - mmd.set_rpm_components(rpm_components) # Add missing data in included modules components - for modname, mod in module_components.items(): + for modname, mod in mmd.get_module_components().items(): if mod.get_repository() and not conf.modules_allow_repository: raise Forbidden( "Custom module repositories aren't allowed. " @@ -133,12 +130,11 @@ def format_mmd(mmd, scmurl, session=None): mod.set_repository(conf.modules_default_repository + modname) if not mod.get_ref(): mod.set_ref('master') - mmd.set_module_components(module_components) # Check that SCM URL is valid and replace potential branches in pkg refs # by real SCM hash and store the result to our private xmd place in modulemd. pool = ThreadPool(20) - pkg_dicts = pool.map(_scm_get_latest, rpm_components.values()) + pkg_dicts = pool.map(_scm_get_latest, mmd.get_rpm_components().values()) err_msg = "" for pkg_dict in pkg_dicts: if pkg_dict["error"]: diff --git a/tests/__init__.py b/tests/__init__.py index cf2a1d32..bf5efa32 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -291,9 +291,7 @@ def scheduler_init_data(tangerine_state=None): current_dir, 'staged_data', 'formatted_testmodule.yaml') mmd = Modulemd.Module().new_from_file(formatted_testmodule_yml_path) mmd.upgrade() - components = mmd.get_rpm_components() - components['tangerine'].set_buildorder(0) - mmd.set_rpm_components(components) + mmd.get_rpm_components()['tangerine'].set_buildorder(0) build_one = module_build_service.models.ModuleBuild() build_one.name = 'testmodule' diff --git a/tests/test_utils/test_utils.py b/tests/test_utils/test_utils.py index 7fb0682c..1c494b28 100644 --- a/tests/test_utils/test_utils.py +++ b/tests/test_utils/test_utils.py @@ -90,9 +90,8 @@ class TestUtilsComponentReuse: second_module_build = models.ModuleBuild.query.filter_by(id=3).one() if changed_component: mmd = second_module_build.mmd() - components = mmd.get_rpm_components() - components['tangerine'].set_ref('00ea1da4192a2030f9ae023de3b3143ed647bbab') - mmd.set_rpm_components(components) + mmd.get_rpm_components()['tangerine'].set_ref( + '00ea1da4192a2030f9ae023de3b3143ed647bbab') second_module_build.modulemd = mmd.dumps() second_module_changed_component = models.ComponentBuild.query.filter_by( package=changed_component, module_id=3).one() @@ -205,9 +204,7 @@ class TestUtilsComponentReuse: mmd = second_module_build.mmd() br_list = Modulemd.SimpleSet() br_list.add('master') - deps = mmd.get_dependencies() - deps[0].set_buildrequires({'some_module': br_list}) - mmd.set_dependencies(deps) + mmd.get_dependencies()[0].set_buildrequires({'some_module': br_list}) xmd = glib.from_variant_dict(mmd.get_xmd()) xmd['mbs']['buildrequires'] = { 'some_module': { @@ -309,11 +306,9 @@ class TestUtils: mmd = Modulemd.Module().new_from_file( path.join(BASE_DIR, '..', 'staged_data', 'testmodule.yaml')) mmd.upgrade() - components = mmd.get_rpm_components() # Modify the component branches so we can identify them later on - components['perl-Tangerine'].set_ref('f28') - components['tangerine'].set_ref('f27') - mmd.set_rpm_components(components) + mmd.get_rpm_components()['perl-Tangerine'].set_ref('f28') + mmd.get_rpm_components()['tangerine'].set_ref('f27') module_build_service.utils.format_mmd(mmd, scmurl) # Make sure that original refs are not changed.