combine code for noting params in xmd

This commit is contained in:
Mike McLean
2022-08-09 08:59:34 -04:00
parent 1ff8f66c02
commit 879e3befae

View File

@@ -270,37 +270,29 @@ def _apply_dep_overrides(mmd, params):
)
def _apply_rpm_component_ref_overrides(mmd, params):
def _apply_xmd_params(mmd, params):
"""
If `rpm_component_ref_overrides` is given, note it in the xmd.
Note some parameters in the mbs section of the xmd.
:param Modulemd.ModuleStream mmd: the modulemd to apply the overrides on
:param dict params: the API parameters passed in by the user
"""
xmd_updates = {}
ref_overrides = params.get("rpm_component_ref_overrides", {})
if not ref_overrides:
# No changes needed.
return
xmd = mmd.get_xmd()
xmd.setdefault("mbs", {})["rpm_component_ref_overrides"] = ref_overrides
mmd.set_xmd(xmd)
def _apply_side_tag(mmd, params):
"""
If a side tag identifier is given, note it in the xmd
:param Modulemd.ModuleStream mmd: the modulemd to apply the overrides on
:param dict params: the API parameters passed in by the user
"""
if ref_overrides:
xmd_updates["rpm_component_ref_overrides"] = ref_overrides
side_tag = params.get('side_tag')
if not side_tag:
# no changes needed
return
if side_tag:
xmd_updates["side_tag"] = side_tag
branch = params.get('side_tag')
if side_tag:
xmd_updates["branch"] = branch
if not xmd_updates:
return
xmd = mmd.get_xmd()
xmd.setdefault("mbs", {})["side_tag"] = side_tag
xmd.setdefault("mbs", {}).update(xmd_updates)
mmd.set_xmd(xmd)
@@ -617,8 +609,7 @@ def submit_module_build(db_session, username, stream_or_packager, params, module
for mmd in input_mmds:
validate_mmd(mmd)
_apply_dep_overrides(mmd, params)
_apply_side_tag(mmd, params)
_apply_rpm_component_ref_overrides(mmd, params)
_apply_xmd_params(mmd, params)
_modify_buildtime_streams(db_session, mmd, resolve_base_module_virtual_streams)
_process_support_streams(db_session, mmd, params)
mmds += generate_expanded_mmds(db_session, mmd, raise_if_stream_ambigous,