Skip to content

Commit

Permalink
feat(entrypoint): add CreatCDEntrypoint
Browse files Browse the repository at this point in the history
Related issues: PSCE-256
Majority of code generated by chatGPT
Signed-off-by: Alex Flom <[email protected]>
  • Loading branch information
afflom authored and jpower432 committed Oct 23, 2023
1 parent 88cf980 commit f4170a8
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions trestlebot/entrypoints/create_cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from trestlebot.tasks.regenerate_task import RegenerateTask
from trestlebot.tasks.rule_transform_task import RuleTransformTask
from trestlebot.transformers.yaml_transformer import ToRulesYAMLTransformer
from trestlebot.const import RULES_VIEW_DIR


class CreateCDEntrypoint(EntrypointBase):
Expand Down Expand Up @@ -53,6 +54,19 @@ def setup_set_default_component_fields_arguments(self) -> None:
default="service",
help="Type of component definition",
)
self.parser.add_argument(
"--generate",
required=False,
default=False,
help="Generate markdown and ssp index",
)
self.parser.add_argument(
"--transform-rules",
required=False,
default=False,
help="Transform rules to YAML",
)


def run(self, args: argparse.Namespace) -> None:
"""Run the entrypoint."""
Expand All @@ -64,25 +78,25 @@ def run(self, args: argparse.Namespace) -> None:
args.comp_description,
args.cd_type,
)

transformer: ToRulesYAMLTransformer = ToRulesYAMLTransformer()

rule_transform_task: RuleTransformTask = RuleTransformTask(
args.working_dir,
args.rules_view_path,
transformer,
comma_sep_to_list(args.skip_items),
)
pre_tasks: List[TaskBase] = [rule_transform_task]

regenerate_task = RegenerateTask(
args.working_dir,
args.oscal_model,
args.markdown_path,
args.ssp_index_path,
comma_sep_to_list(args.skip_items),
)
pre_tasks.append(regenerate_task)
pre_tasks: List[TaskBase] = []
if args.transform_rules:
transformer: ToRulesYAMLTransformer = ToRulesYAMLTransformer()
rule_transform_task: RuleTransformTask = RuleTransformTask(
args.working_dir,
args.RULES_VIEW_DIR,
transformer,
comma_sep_to_list(args.skip_items),
)
pre_tasks: List[TaskBase] = [rule_transform_task]
if args.generate:
regenerate_task = RegenerateTask(
args.working_dir,
"compdef",
args.markdown_path,
args.ssp_index_path,
comma_sep_to_list(args.skip_items),
)
pre_tasks.append(regenerate_task)

super().run_base(args, pre_tasks)

Expand Down

0 comments on commit f4170a8

Please sign in to comment.