Skip to content

Commit 0fd7071

Browse files
committed
Add content list to container push repositories
fixes #600
1 parent 8437376 commit 0fd7071

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

CHANGES/600.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added the content list commands to container push repositories.

pulpcore/cli/common/generic.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,10 @@ def repository_content_command(**kwargs: t.Any) -> click.Group:
15301530
"""A factory that creates a repository content command group."""
15311531

15321532
content_contexts = kwargs.pop("contexts", {})
1533+
list_kwargs = kwargs.pop("list_kwargs", {})
1534+
add_kwargs = kwargs.pop("add_kwargs", {})
1535+
remove_kwargs = kwargs.pop("remove_kwargs", {})
1536+
modify_kwargs = kwargs.pop("modify_kwargs", {})
15331537

15341538
def version_callback(
15351539
ctx: click.Context, param: click.Parameter, value: t.Optional[int]
@@ -1540,7 +1544,7 @@ def version_callback(
15401544

15411545
# This is a mypy bug getting confused with positional args
15421546
# https://github.com/python/mypy/issues/15037
1543-
@pulp_command("list") # type: ignore [arg-type]
1547+
@pulp_command("list", **list_kwargs) # type: ignore [arg-type]
15441548
@click.option("--all-types", is_flag=True)
15451549
@limit_option
15461550
@offset_option
@@ -1563,7 +1567,7 @@ def content_list(
15631567
result = content_ctx.list(limit=limit, offset=offset, parameters=parameters)
15641568
pulp_ctx.output_result(result)
15651569

1566-
@pulp_command("add")
1570+
@pulp_command("add", **add_kwargs)
15671571
@repository_option
15681572
@click.option("--base-version", type=int, callback=version_callback)
15691573
@pass_content_context
@@ -1574,7 +1578,7 @@ def content_add(
15741578
repo_ctx = base_version.repository_ctx
15751579
repo_ctx.modify(add_content=[content_ctx.pulp_href], base_version=base_version.pulp_href)
15761580

1577-
@pulp_command("remove")
1581+
@pulp_command("remove", **remove_kwargs)
15781582
@click.option("--all", is_flag=True, help=_("Remove all content from repository version"))
15791583
@repository_option
15801584
@click.option("--base-version", type=int, callback=version_callback)
@@ -1588,7 +1592,7 @@ def content_remove(
15881592
remove_content = ["*" if all else content_ctx.pulp_href]
15891593
repo_ctx.modify(remove_content=remove_content, base_version=base_version.pulp_href)
15901594

1591-
@pulp_command("modify")
1595+
@pulp_command("modify", **modify_kwargs)
15921596
@repository_option
15931597
@click.option("--base-version", type=int, callback=version_callback)
15941598
def content_modify(

pulpcore/cli/container/repository.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ def repository() -> None:
135135
contexts=contexts,
136136
add_decorators=show_options,
137137
remove_decorators=show_options,
138-
allowed_with_contexts=container_context,
138+
add_kwargs={"allowed_with_contexts": container_context},
139+
remove_kwargs={"allowed_with_contexts": container_context},
140+
modify_kwargs={"allowed_with_contexts": container_context},
139141
)
140142
)
141143

tests/scripts/pulp_container/test_content.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pulp debug has-plugin --name "container" || exit 23
77

88
cleanup() {
99
pulp container repository destroy --name "cli_test_container_repository" || true
10+
pulp container repository destroy --name "cli_test_container_push_repository" || true
1011
pulp container remote destroy --name "cli_test_container_remote" || true
1112
pulp orphan cleanup || true
1213
}
@@ -16,6 +17,7 @@ trap cleanup EXIT
1617
pulp container remote create --name "cli_test_container_remote" --url "$CONTAINER_REMOTE_URL" --upstream-name "$CONTAINER_IMAGE"
1718
pulp container repository create --name "cli_test_container_repository"
1819
pulp container repository sync --name "cli_test_container_repository" --remote "cli_test_container_remote"
20+
pulp container repository create --name "cli_test_container_push_repository"
1921

2022
# Check each content list
2123
expect_succ pulp container content -t blob list
@@ -59,3 +61,8 @@ expect_succ pulp container repository content --type "tag" remove --repository "
5961
expect_succ pulp container repository content add --repository "cli_test_container_repository" --href "$blob_href"
6062
expect_succ pulp container repository content add --repository "cli_test_container_repository" --href "$manifest_href"
6163
expect_succ pulp container repository content add --repository "cli_test_container_repository" --href "$tag_href"
64+
65+
expect_succ pulp container repository -t push content list --repository "cli_test_container_push_repository" --all-types
66+
expect_succ pulp container repository -t push content --type "tag" list --repository "cli_test_container_push_repository"
67+
expect_succ pulp container repository -t push content --type "manifest" list --repository "cli_test_container_push_repository"
68+
expect_succ pulp container repository -t push content --type "blob" list --repository "cli_test_container_push_repository"

0 commit comments

Comments
 (0)