Skip to content

Commit

Permalink
476 tdp operations (#487)
Browse files Browse the repository at this point in the history
* feat: modified function operation in cli commands to ops

* fix: make the --host option work without calling --dag

---------

Co-authored-by: SteBaum <[email protected]>
  • Loading branch information
SteBaum and SteBaum authored Oct 31, 2023
1 parent d577ca4 commit 285b9b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tdp/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from tdp.cli.commands.default_diff import default_diff
from tdp.cli.commands.deploy import deploy
from tdp.cli.commands.init import init
from tdp.cli.commands.operations import operations
from tdp.cli.commands.operations import ops
from tdp.cli.commands.plan import plan
from tdp.cli.commands.playbooks import playbooks
from tdp.cli.commands.status import status
Expand Down Expand Up @@ -62,7 +62,7 @@ def main():
cli.add_command(default_diff)
cli.add_command(deploy)
cli.add_command(init)
cli.add_command(operations)
cli.add_command(ops)
cli.add_command(plan)
cli.add_command(playbooks)
cli.add_command(status)
Expand Down
14 changes: 8 additions & 6 deletions tdp/cli/commands/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
help="Display DAG operations in topological order.",
)
@collections
def operations(
def ops(
collections: Collections,
display_dag_operations: bool,
hosts: list[str],
Expand All @@ -54,11 +54,13 @@ def operations(
sorted_operations = sorted(operations, key=lambda operation: operation.name)
_print_operations(sorted_operations)
else:
_print_operations(
sorted(
collections.operations.values(), key=lambda operation: operation.name
)
)
operations = [
operation
for operation in collections.operations.values()
if len(hosts) == 0 or bool(set(operation.host_names) & set(hosts))
]
sorted_operations = sorted(operations, key=lambda operation: operation.name)
_print_operations(sorted_operations)


def _print_operations(operations: Iterable[Operation], /):
Expand Down
4 changes: 2 additions & 2 deletions tdp/cli/commands/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

from click.testing import CliRunner

from tdp.cli.commands.operations import operations
from tdp.cli.commands.operations import ops


def test_tdp_nodes(collection_path: Path):
args = ["--collection-path", collection_path]
runner = CliRunner()
result = runner.invoke(operations, args)
result = runner.invoke(ops, args)
assert result.exit_code == 0, result.output

0 comments on commit 285b9b4

Please sign in to comment.