Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

476 tdp operations #487

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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