Skip to content

Commit

Permalink
chore(RHTAPWATCH-662): add inputs to odcs compose entrypoint
Browse files Browse the repository at this point in the history
Required inputs when running the odcs entrypoint to specify where
the compose should be stored and where the configurations reside.

Had to rename the directory name to avoid it having the same name
as one of the the modules.

Signed-off-by: Yftach Herzog <[email protected]>
  • Loading branch information
yftacherzog committed Dec 7, 2023
1 parent 8831254 commit 2b1fdf5
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 35 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ black = "*"
mypy = "*"
pylint = "*"
isort = "*"
pyyaml = "*"

[dev-packages]

Expand Down
58 changes: 57 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions compose_generator/odcs_compose_generator.py

This file was deleted.

2 changes: 1 addition & 1 deletion format.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -ex

main() {
local pkgs=("tests" "compose_generator")
local pkgs=("tests" "generate_compose")
pipenv run isort --profile black "${pkgs[@]}"
pipenv run black "${pkgs[@]}"
}
Expand Down
File renamed without changes.
File renamed without changes.
60 changes: 60 additions & 0 deletions generate_compose/odcs_compose_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3

"""Initialize and use a compose generator using ODCS"""

from pathlib import Path
from typing import Optional

import click
import yaml

from .compose_generator import ComposeGenerator
from .odcs_configurations_generator import ODCSConfigurationsGenerator
from .odcs_fetcher import ODCSFetcher
from .odcs_requester import ODCSRequester


@click.command()
@click.option(
"--target-path",
help="Path to where the compose should be saved.",
type=click.Path(path_type=Path),
required=True,
)
@click.option(
"--container-yaml-path",
help="Path in which container yaml file is stored",
type=click.Path(path_type=Path),
required=True,
)
@click.option(
"--content-sets-yaml-path",
help="Path in which content_sets yaml file is stored",
type=click.Path(path_type=Path),
required=True,
)
def main(
target_path: Path,
container_yaml_path: Path,
content_sets_yaml_path: Path,
):
"""
Get inputs from container and content_sets yamls and relay them to an ODCS
compose generator that will request a compose and store it in a TBD location.
"""
container_data: dict = yaml.safe_load(container_yaml_path.read_text())
content_sets_data: dict = yaml.safe_load(content_sets_yaml_path.read_text())

compose_generator = ComposeGenerator(
configurations_generator=ODCSConfigurationsGenerator(
container_data=container_data,
content_sets_data=content_sets_data,
),
requestor=ODCSRequester(),
fetcher=ODCSFetcher(target_path=target_path),
)
compose_generator()


if __name__ == "__main__":
main() # pylint: disable=no-value-for-parameter
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Fetch ready ODCS compose"""
from dataclasses import dataclass
from pathlib import Path
from typing import Optional

from .protocols import ComposeFetcher, ComposeReference

Expand All @@ -16,6 +17,8 @@ class ODCSResultReference(ComposeReference):

@dataclass(frozen=True)
class ODCSFetcher(ComposeFetcher):
target_path: Optional[Path]

"""
Fetch ODCS compose based on a remote compose-reference and store it locally
"""
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_static_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from subprocess import run
from typing import Final

PKGS: Final[list[str]] = ["tests", "compose_generator"]
PKGS: Final[list[str]] = ["tests", "generate_compose"]


def test_mypy() -> None:
Expand Down

0 comments on commit 2b1fdf5

Please sign in to comment.