Skip to content

Commit

Permalink
fix: improve the validation components with parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Sophia Wang <huiwang@redhat.com>
  • Loading branch information
huiwangredhat committed Jan 15, 2025
1 parent f59f4fe commit 27b0733
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions trestlebot/transformers/cac_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,38 @@ def get_validation_component_mapping(props: Property) -> List[Dict[str, str]]:
"Rule_Id" value and "Rule_Description".
Args:
props (List[Dict]): The input list of dictionaries.
props (Property): The input of Property.
Returns:
List[Dict]: The updated list with the new "Check_Id" and
"Check_Description" entry.
"""
transformed_list = [transform_property(prop) for prop in props]
rule_check_mapping = []
check_id_entry = {}
for prop in transformed_list:
rule_check_mapping.append(prop)
if prop["name"] == "Rule_Id":
rule_check_mapping.append(prop)
check_id_entry = {
"name": "Check_Id",
"ns": prop["ns"],
"value": prop["value"],
"remarks": prop["remarks"],
}
if prop["name"] == "Rule_Description":
rule_check_mapping.append(prop)
rule_check_mapping.append(check_id_entry)
check_description_entry = {
"name": "Check_Description",
"ns": prop["ns"],
"value": prop["value"],
"remarks": prop["remarks"],
}
# Append the Check entry follow Rule_Description
rule_check_mapping.append(check_id_entry)
rule_check_mapping.append(check_description_entry)
# If this rule has paramters, append the Check entry follow paramters
if prop["name"] == "Parameter_Value_Alternatives":
rule_check_mapping.remove(check_id_entry)
rule_check_mapping.remove(check_description_entry)
rule_check_mapping.append(check_id_entry)
rule_check_mapping.append(check_description_entry)
return rule_check_mapping

Expand Down

0 comments on commit 27b0733

Please sign in to comment.