Skip to content

Commit

Permalink
add the sync cac content task to push local change to remote
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 7, 2025
1 parent cfa689d commit f1e4148
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
15 changes: 13 additions & 2 deletions trestlebot/cli/commands/sync_cac_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

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

import click

from trestlebot.cli.options.common import common_options, git_options, handle_exceptions
from trestlebot.cli.utils import run_bot
from trestlebot.tasks.authored.compdef import AuthoredComponentDefinition
from trestlebot.tasks.base_task import TaskBase
from trestlebot.tasks.sync_cac_content_task import SyncCacContentTask


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -60,7 +63,7 @@ def sync_cac_content_cmd(ctx: click.Context, **kwargs: Any) -> None:
# 3. Create a new task to run the data transformation.
# 4. Initialize a Trestlebot object and run the task(s).

# pre_tasks: List[TaskBase] = []
pre_tasks: List[TaskBase] = []

product = kwargs["product"]
cac_content_root = kwargs["cac_content_root"]
Expand All @@ -76,3 +79,11 @@ def sync_cac_content_cmd(ctx: click.Context, **kwargs: Any) -> None:
cac_content_root=cac_content_root,
working_dir=working_dir,
)

sync_cac_content_task: SyncCacContentTask = SyncCacContentTask(
working_dir=working_dir
)

pre_tasks.append(sync_cac_content_task)

run_bot(pre_tasks, kwargs)
35 changes: 35 additions & 0 deletions trestlebot/tasks/sync_cac_content_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2023 Red Hat, Inc.


"""Trestle Bot Rule Transform Tasks"""

from typing import Optional

import trestlebot.const as const
from trestlebot.tasks.base_task import ModelFilter, TaskBase


class SyncCacContentTask(TaskBase):
"""
Transform rules into OSCAL content.
"""

def __init__(
self,
working_dir: str,
model_filter: Optional[ModelFilter] = None,
) -> None:
"""
Initialize transform task.
Args:
working_dir: Working directory to complete operations in
model_filter: Optional filter to apply to the task to include or exclude models
from processing.
"""
super().__init__(working_dir, model_filter)

def execute(self) -> int:
"""Execute task"""
return const.SUCCESS_EXIT_CODE

0 comments on commit f1e4148

Please sign in to comment.