Skip to content

Commit

Permalink
fix: updates ssp-assemble to ensure existing leveraged comps persist
Browse files Browse the repository at this point in the history
Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Sep 28, 2023
1 parent 807bb28 commit 725f698
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions trestle/core/commands/author/ssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,18 @@ def _run(self, args: argparse.Namespace) -> int:
raise TrestleError('Original ssp has no system component.')
comp_dict[const.SSP_MAIN_COMP_NAME] = sys_comp

ssp_sys_imp_comps = ssp.system_implementation.components
# Gather the leveraged components to add back after the merge
leveraged_comps: Dict[str, ossp.SystemComponent] = {}
for sys_comp in ssp_sys_imp_comps:
if sys_comp.props is not None:
prop_names = [x.name for x in sys_comp.props]
if const.LEV_AUTH_UUID in prop_names:
leveraged_comps[sys_comp.title] = sys_comp

# Verifies older compdefs in an ssp no longer exist in newly provided ones
comp_titles = [x.title for x in comp_dict.values()]
ssp_sys_imp_comps = ssp.system_implementation.components
diffs = [x for x in ssp_sys_imp_comps if x.title not in comp_titles]
diffs = [x for x in ssp_sys_imp_comps if x.title not in comp_titles and x.title not in leveraged_comps]
if diffs:
for diff in diffs:
logger.warning(
Expand All @@ -581,6 +589,9 @@ def _run(self, args: argparse.Namespace) -> int:
CatalogReader.read_ssp_md_content(md_path, ssp, comp_dict, part_id_map_by_label, context)

new_file_content_type = FileContentType.path_to_content_type(orig_ssp_path)

# Add the leveraged comps back to the final ssp
ssp.system_implementation.components.extend(list(leveraged_comps.values()))
else:
# create a sample ssp to hold all the parts
ssp = gens.generate_sample_model(ossp.SystemSecurityPlan)
Expand Down

0 comments on commit 725f698

Please sign in to comment.