Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGES/1439.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added the `--retain-checkpoints` option to file and rpm repositories.
2 changes: 1 addition & 1 deletion pulp-glue/src/pulp_glue/common/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ class PulpRepositoryContext(PulpEntityContext):
HREF_TEMPLATE = "repositories/{plugin}/{resource_type}/{pulp_id}/"
ID_PREFIX = "repositories"
VERSION_CONTEXT: t.ClassVar[type[PulpRepositoryVersionContext]] = PulpRepositoryVersionContext
NULLABLES = {"description", "remote", "retain_repo_versions"}
NULLABLES = {"description", "remote", "retain_repo_versions", "retain_checkpoints"}
TYPE_REGISTRY: t.Final[dict[str, type["PulpRepositoryContext"]]] = {}

def __init_subclass__(cls, **kwargs: t.Any) -> None:
Expand Down
7 changes: 7 additions & 0 deletions src/pulp_cli/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,13 @@ def _type_callback(ctx: click.Context, param: click.Parameter, value: str | None
type=int_or_empty,
)

retain_checkpoints_option = pulp_option(
"--retain-checkpoints",
needs_plugins=[PluginRequirement("core", specifier=">=3.106.0")],
help=_("Number of checkpoint publications to keep. Leave empty to retain all checkpoints."),
type=int_or_empty,
)

pulp_labels_option = pulp_option(
"--labels",
"pulp_labels",
Expand Down
2 changes: 2 additions & 0 deletions src/pulpcore/cli/file/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
repository_href_option,
repository_lookup_option,
resource_option,
retain_checkpoints_option,
retained_versions_option,
role_command,
show_command,
Expand Down Expand Up @@ -107,6 +108,7 @@ def repository() -> None:
default=None,
),
retained_versions_option,
retain_checkpoints_option,
pulp_labels_option,
]
create_options = update_options + [click.option("--name", required=True)]
Expand Down
2 changes: 2 additions & 0 deletions src/pulpcore/cli/rpm/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
repository_href_option,
repository_lookup_option,
resource_option,
retain_checkpoints_option,
retained_versions_option,
role_command,
show_command,
Expand Down Expand Up @@ -194,6 +195,7 @@ def repository() -> None:
default=None,
),
retained_versions_option,
retain_checkpoints_option,
pulp_labels_option,
pulp_option(
"--repo-config",
Expand Down
11 changes: 11 additions & 0 deletions tests/scripts/pulp_file/test_repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ test "$(echo "$OUTPUT" | jq -r '.|length')" != "0"
expect_succ pulp file repository task list --repository "cli_test_file_repo"
test "$(echo "$OUTPUT" | jq -r '.|length')" = "6"

# retain_checkpoints was added to Repository in pulpcore 3.106.0 (pulp/pulpcore#7428)
if pulp debug has-plugin --name "core" --specifier ">=3.106.0"
then
expect_succ pulp file repository update --repository "cli_test_file_repo" --retain-checkpoints 5
expect_succ pulp file repository show --repository "cli_test_file_repo"
test "$(echo "$OUTPUT" | jq -r '.retain_checkpoints')" = "5"
expect_succ pulp file repository update --repository "cli_test_file_repo" --retain-checkpoints ""
expect_succ pulp file repository show --repository "cli_test_file_repo"
test "$(echo "$OUTPUT" | jq -r '.retain_checkpoints')" = "null"
fi

if pulp debug has-plugin --name "file" --specifier ">=1.7.0"
then
expect_succ pulp file repository update --repository "cli_test_file_repo" --manifest "manifest.csv"
Expand Down
11 changes: 11 additions & 0 deletions tests/scripts/pulp_rpm/test_rpm_sync_publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ expect_succ pulp rpm repository update --repository "cli_test_rpm_sync_repositor
expect_succ pulp rpm repository show --repository "cli_test_rpm_sync_repository"
test "$(echo "$OUTPUT" | jq -r '.description')" = "null"

# retain_checkpoints was added to Repository in pulpcore 3.106.0 (pulp/pulpcore#7428)
if pulp debug has-plugin --name "core" --specifier ">=3.106.0"
then
expect_succ pulp rpm repository update --repository "cli_test_rpm_sync_repository" --retain-checkpoints 5
expect_succ pulp rpm repository show --repository "cli_test_rpm_sync_repository"
test "$(echo "$OUTPUT" | jq -r '.retain_checkpoints')" = "5"
expect_succ pulp rpm repository update --repository "cli_test_rpm_sync_repository" --retain-checkpoints ""
expect_succ pulp rpm repository show --repository "cli_test_rpm_sync_repository"
test "$(echo "$OUTPUT" | jq -r '.retain_checkpoints')" = "null"
fi

# sqlite metadata removal from pulp_rpm (pulp/pulp_rpm#3328)
if pulp debug has-plugin --name "rpm" --specifier "<3.25.0"
then
Expand Down
Loading