Skip to content

Commit

Permalink
feat: initialize command for cac to oscal transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
qduanmu committed Dec 20, 2024
1 parent 0314389 commit e49e24e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
60 changes: 60 additions & 0 deletions trestlebot/cli/commands/sync_cac_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Red Hat, Inc.

"""Module for sync cac content command"""
import logging
from typing import Any

import click

from trestlebot.cli.options.common import common_options, git_options, handle_exceptions


logger = logging.getLogger(__name__)


@click.command(
name="sync-cac-content",
help="Transform CaC content to component definition in OSCAL.",
)
@click.pass_context
@common_options
@git_options
@click.option(
"--cac-content-root",
help="Root of the CaC content project.",
required=True,
)
@click.option(
"--product",
type=str,
help="Product to build OSCAL component definition with",
required=True,
)
@click.option(
"--control",
type=str,
help="Control to use as the source for control responses",
required=True,
)
@click.option(
"--profile",
type=str,
help="Main profile href, or name of the profile in trestle workspace",
required=True,
)
@click.option(
"--component-definition-type",
type=click.Choice(["service", "validation"]),
help="Type of component definition",
required=False,
default="service",
)
@handle_exceptions
def sync_cac_content_cmd(ctx: click.Context, **kwargs: Any) -> None:
"""Transform CaC content to OSCAL component definition."""

# TODO:
# 1. Check options, logger errors if any and exit.
# 2. Create a new task to run the data transformation.
# 3. Initialize a Trestlebot object and run the task(s).
2 changes: 2 additions & 0 deletions trestlebot/cli/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from trestlebot.cli.commands.create import create_cmd
from trestlebot.cli.commands.init import init_cmd
from trestlebot.cli.commands.rule_transform import rule_transform_cmd
from trestlebot.cli.commands.sync_cac_content import sync_cac_content_cmd
from trestlebot.cli.commands.sync_upstreams import sync_upstreams_cmd


Expand All @@ -33,4 +34,5 @@ def root_cmd(ctx: click.Context) -> None:
root_cmd.add_command(autosync_cmd)
root_cmd.add_command(create_cmd)
root_cmd.add_command(rule_transform_cmd)
root_cmd.add_command(sync_cac_content_cmd)
root_cmd.add_command(sync_upstreams_cmd)

0 comments on commit e49e24e

Please sign in to comment.