diff --git a/trestlebot/cli/commands/sync_cac_content.py b/trestlebot/cli/commands/sync_cac_content.py index 04b5cdca..9ec03554 100644 --- a/trestlebot/cli/commands/sync_cac_content.py +++ b/trestlebot/cli/commands/sync_cac_content.py @@ -64,7 +64,6 @@ def sync_cac_content_cmd(ctx: click.Context, **kwargs: Any) -> None: product = kwargs["product"] cac_content_root = kwargs["cac_content_root"] - component_description = kwargs["product"] component_definition_type = kwargs.get("component_definition_type", "service") working_dir = kwargs["repo_path"] @@ -72,7 +71,6 @@ def sync_cac_content_cmd(ctx: click.Context, **kwargs: Any) -> None: trestle_root=working_dir, ) authored_comp.create_update_cac_compdef( - comp_description=component_description, comp_type=component_definition_type, product=product, cac_content_root=cac_content_root, diff --git a/trestlebot/tasks/authored/compdef.py b/trestlebot/tasks/authored/compdef.py index b9fa7a0a..68a4b236 100644 --- a/trestlebot/tasks/authored/compdef.py +++ b/trestlebot/tasks/authored/compdef.py @@ -26,7 +26,7 @@ AuthoredObjectException, ) from trestlebot.transformers.cac_transformer import ( - get_component_title, + get_component_info, update_component_definition, ) from trestlebot.transformers.trestle_rule import ( @@ -171,7 +171,6 @@ def create_new_default( def create_update_cac_compdef( self, - comp_description: str, comp_type: str, product: str, cac_content_root: str, @@ -192,9 +191,10 @@ def create_update_cac_compdef( component_definition.metadata.version = "1.0" component_definition.components = list() oscal_component = generate_sample_model(DefinedComponent) - oscal_component.title = get_component_title(product, cac_content_root) + product_name, full_name = get_component_info(product, cac_content_root) + oscal_component.title = product_name + oscal_component.description = full_name oscal_component.type = comp_type - oscal_component.description = comp_description # Create all of the component properties for rules # This part will be updated in CPLYTM-218 @@ -212,9 +212,7 @@ def create_update_cac_compdef( with open(ofile, "r", encoding="utf-8") as f: data = json.load(f) for component in data["component-definition"]["components"]: - if component.get("title") == get_component_title( - product, cac_content_root - ): + if component.get("title") == oscal_component.title: logger.info("Update the exsisting component definition.") # Need to update props parts if the rules updated # Update the version and last modify time diff --git a/trestlebot/transformers/cac_transformer.py b/trestlebot/transformers/cac_transformer.py index e9363b63..0cba242d 100644 --- a/trestlebot/transformers/cac_transformer.py +++ b/trestlebot/transformers/cac_transformer.py @@ -4,11 +4,12 @@ import datetime import json from pathlib import Path +from typing import Tuple from ssg.products import load_product_yaml, product_yaml_path -def get_component_title(product_name: str, cac_path: str) -> str: +def get_component_info(product_name: str, cac_path: str) -> Tuple[str, str]: """Get the product name from product yml file via the SSG library.""" if product_name and cac_path: # Get the product yaml file path @@ -16,7 +17,9 @@ def get_component_title(product_name: str, cac_path: str) -> str: # Load the product data product = load_product_yaml(product_yml_path) # Return product name from product yml file - return product._primary_data.get("product") + component_title = product._primary_data.get("product") + component_description = product._primary_data.get("full_name") + return (component_title, component_description) else: raise ValueError("component_title is empty or None")