diff --git a/CHANGES/254.feature b/CHANGES/254.feature new file mode 100644 index 000000000..25d99e5bf --- /dev/null +++ b/CHANGES/254.feature @@ -0,0 +1 @@ +Added generic content list command. diff --git a/pulpcore/cli/core/__init__.py b/pulpcore/cli/core/__init__.py index b00ae23dc..02487e5b8 100644 --- a/pulpcore/cli/core/__init__.py +++ b/pulpcore/cli/core/__init__.py @@ -3,6 +3,7 @@ from pulpcore.cli.common import main from pulpcore.cli.core.access_policy import access_policy from pulpcore.cli.core.artifact import artifact +from pulpcore.cli.core.content import content from pulpcore.cli.core.export import export from pulpcore.cli.core.exporter import exporter from pulpcore.cli.core.group import group @@ -22,6 +23,7 @@ # Register commands with cli main.add_command(access_policy) main.add_command(artifact) +main.add_command(content) main.add_command(export) main.add_command(exporter) main.add_command(group) diff --git a/pulpcore/cli/core/content.py b/pulpcore/cli/core/content.py new file mode 100644 index 000000000..3cc0744f3 --- /dev/null +++ b/pulpcore/cli/core/content.py @@ -0,0 +1,25 @@ +import gettext + +import click + +from pulpcore.cli.common.context import PulpContentContext, PulpContext, pass_pulp_context +from pulpcore.cli.common.generic import list_command + +_ = gettext.gettext + + +@click.group() +@pass_pulp_context +@click.pass_context +def content(ctx: click.Context, pulp_ctx: PulpContext) -> None: + """ + Perform actions on all content units. + + Please look for the plugin specific content commands for more detailed actions. + i.e. 'pulp file content <...>' + """ + pulp_ctx.needs_plugin("core", min_version="3.10") + ctx.obj = PulpContentContext(pulp_ctx) + + +content.add_command(list_command()) diff --git a/pulpcore/cli/core/repository.py b/pulpcore/cli/core/repository.py index 56c51d316..1e55055b6 100644 --- a/pulpcore/cli/core/repository.py +++ b/pulpcore/cli/core/repository.py @@ -18,7 +18,7 @@ def repository(ctx: click.Context, pulp_ctx: PulpContext) -> None: Please look for the plugin specific repository commands for more detailed actions. i.e. 'pulp file repository <...>' """ - pulp_ctx.needs_plugin("core", min_version="3.10.dev") + pulp_ctx.needs_plugin("core", min_version="3.10") ctx.obj = PulpRepositoryContext(pulp_ctx) diff --git a/tests/scripts/pulp_file/test_content.sh b/tests/scripts/pulp_file/test_content.sh index f614acac5..ce5d5f77d 100755 --- a/tests/scripts/pulp_file/test_content.sh +++ b/tests/scripts/pulp_file/test_content.sh @@ -52,3 +52,9 @@ fi expect_succ pulp file repository content remove --repository "cli_test_file_repository" --sha256 "$sha256" --relative-path upload_test/test.txt expect_succ pulp file repository content list --repository "cli_test_file_repository" test "$(echo "$OUTPUT" | jq -r length)" -eq "0" + +if pulp debug has-plugin --name "core" --min-version "3.10" +then + expect_succ pulp content list + test "$(echo "$OUTPUT" | jq -r length)" -gt "0" +fi diff --git a/tests/scripts/pulp_file/test_repository.sh b/tests/scripts/pulp_file/test_repository.sh index eb1fc7d4a..da4ce20d9 100755 --- a/tests/scripts/pulp_file/test_repository.sh +++ b/tests/scripts/pulp_file/test_repository.sh @@ -39,7 +39,7 @@ then expect_succ pulp file repository update --name "cli_test_file_repo" --manifest "manifest.csv" fi -if pulp debug has-plugin --name "core" --min-version "3.10.dev" +if pulp debug has-plugin --name "core" --min-version "3.10" then expect_succ pulp repository list test "$(echo "$OUTPUT" | jq -r '.|length')" != "0"