Skip to content

Commit

Permalink
Add content list command
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
mdellweg committed May 22, 2021
1 parent 453041e commit 7290154
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/254.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added generic content list command.
2 changes: 2 additions & 0 deletions pulpcore/cli/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions pulpcore/cli/core/content.py
Original file line number Diff line number Diff line change
@@ -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())
2 changes: 1 addition & 1 deletion pulpcore/cli/core/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
6 changes: 6 additions & 0 deletions tests/scripts/pulp_file/test_content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/scripts/pulp_file/test_repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7290154

Please sign in to comment.