From 0720bee35ae6d78a291a37889a29ddcd41e3a081 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Mon, 26 Apr 2021 11:38:10 +0200 Subject: [PATCH] Add task-group command group [noissue] --- CHANGES/211.feature | 1 + pulpcore/cli/core/__init__.py | 2 ++ pulpcore/cli/core/context.py | 7 +++++++ pulpcore/cli/core/export.py | 2 +- pulpcore/cli/core/task_group.py | 20 ++++++++++++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 CHANGES/211.feature create mode 100644 pulpcore/cli/core/task_group.py diff --git a/CHANGES/211.feature b/CHANGES/211.feature new file mode 100644 index 000000000..2ba6a1389 --- /dev/null +++ b/CHANGES/211.feature @@ -0,0 +1 @@ +Added the task-group subcommand. diff --git a/pulpcore/cli/core/__init__.py b/pulpcore/cli/core/__init__.py index c095be7e9..a5b3d1be9 100644 --- a/pulpcore/cli/core/__init__.py +++ b/pulpcore/cli/core/__init__.py @@ -13,6 +13,7 @@ from pulpcore.cli.core.show import show from pulpcore.cli.core.status import status from pulpcore.cli.core.task import task +from pulpcore.cli.core.task_group import task_group from pulpcore.cli.core.user import user from pulpcore.cli.core.worker import worker @@ -31,5 +32,6 @@ main.add_command(show) main.add_command(status) main.add_command(task) +main.add_command(task_group) main.add_command(user) main.add_command(worker) diff --git a/pulpcore/cli/core/context.py b/pulpcore/cli/core/context.py index 267685bae..badb80e96 100644 --- a/pulpcore/cli/core/context.py +++ b/pulpcore/cli/core/context.py @@ -300,6 +300,13 @@ def scope(self) -> Dict[str, Any]: return {} +class PulpTaskGroupContext(PulpEntityContext): + ENTITY = "task group" + HREF = "task_group_href" + LIST_ID = "task_groups_list" + READ_ID = "task_groups_read" + + class PulpUploadContext(PulpEntityContext): ENTITY = "upload" HREF = "upload_href" diff --git a/pulpcore/cli/core/export.py b/pulpcore/cli/core/export.py index 7bf8fb524..b0409603a 100644 --- a/pulpcore/cli/core/export.py +++ b/pulpcore/cli/core/export.py @@ -67,7 +67,7 @@ def list( exporter: str, limit: int, offset: int, - **kwargs: Any + **kwargs: Any, ) -> None: params = {k: v for k, v in kwargs.items() if v is not None} exporter_ctx = PulpExporterContext(pulp_ctx) diff --git a/pulpcore/cli/core/task_group.py b/pulpcore/cli/core/task_group.py new file mode 100644 index 000000000..bff99be2d --- /dev/null +++ b/pulpcore/cli/core/task_group.py @@ -0,0 +1,20 @@ +import gettext + +import click + +from pulpcore.cli.common.context import PulpContext, pass_pulp_context +from pulpcore.cli.common.generic import href_option, list_command, show_command +from pulpcore.cli.core.context import PulpTaskGroupContext + +_ = gettext.gettext + + +@click.group() +@pass_pulp_context +@click.pass_context +def task_group(ctx: click.Context, pulp_ctx: PulpContext) -> None: + ctx.obj = PulpTaskGroupContext(pulp_ctx) + + +task_group.add_command(list_command()) +task_group.add_command(show_command(decorators=[href_option]))