Skip to content

Commit d745426

Browse files
daviddavismdellweg
authored andcommitted
Add retain_checkpoints support to file and rpm repositories
The retain_checkpoints field was added to Repository in pulpcore 3.106.0 (pulp/pulpcore#7428) and is exposed by the file and rpm repository APIs. This adds the corresponding --retain-checkpoints option to the file and rpm repository create and update commands. These are the only two plugins that currently support checkpoints in the CLI. fixes #1439 Assisted By: GitHub Copilot (Claude Opus 4.8)
1 parent e23ab62 commit d745426

7 files changed

Lines changed: 35 additions & 1 deletion

File tree

CHANGES/1439.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added the `--retain-checkpoints` option to file and rpm repositories.

pulp-glue/src/pulp_glue/common/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ class PulpRepositoryContext(PulpEntityContext):
15821582
HREF_TEMPLATE = "repositories/{plugin}/{resource_type}/{pulp_id}/"
15831583
ID_PREFIX = "repositories"
15841584
VERSION_CONTEXT: t.ClassVar[type[PulpRepositoryVersionContext]] = PulpRepositoryVersionContext
1585-
NULLABLES = {"description", "remote", "retain_repo_versions"}
1585+
NULLABLES = {"description", "remote", "retain_repo_versions", "retain_checkpoints"}
15861586
TYPE_REGISTRY: t.Final[dict[str, type["PulpRepositoryContext"]]] = {}
15871587

15881588
def __init_subclass__(cls, **kwargs: t.Any) -> None:

src/pulp_cli/generic.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,13 @@ def _type_callback(ctx: click.Context, param: click.Parameter, value: str | None
13791379
type=int_or_empty,
13801380
)
13811381

1382+
retain_checkpoints_option = pulp_option(
1383+
"--retain-checkpoints",
1384+
needs_plugins=[PluginRequirement("core", specifier=">=3.106.0")],
1385+
help=_("Number of checkpoint publications to keep. Leave empty to retain all checkpoints."),
1386+
type=int_or_empty,
1387+
)
1388+
13821389
pulp_labels_option = pulp_option(
13831390
"--labels",
13841391
"pulp_labels",

src/pulpcore/cli/file/repository.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
repository_href_option,
3838
repository_lookup_option,
3939
resource_option,
40+
retain_checkpoints_option,
4041
retained_versions_option,
4142
role_command,
4243
show_command,
@@ -107,6 +108,7 @@ def repository() -> None:
107108
default=None,
108109
),
109110
retained_versions_option,
111+
retain_checkpoints_option,
110112
pulp_labels_option,
111113
]
112114
create_options = update_options + [click.option("--name", required=True)]

src/pulpcore/cli/rpm/repository.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
repository_href_option,
3838
repository_lookup_option,
3939
resource_option,
40+
retain_checkpoints_option,
4041
retained_versions_option,
4142
role_command,
4243
show_command,
@@ -194,6 +195,7 @@ def repository() -> None:
194195
default=None,
195196
),
196197
retained_versions_option,
198+
retain_checkpoints_option,
197199
pulp_labels_option,
198200
pulp_option(
199201
"--repo-config",

tests/scripts/pulp_file/test_repository.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ test "$(echo "$OUTPUT" | jq -r '.|length')" != "0"
4242
expect_succ pulp file repository task list --repository "cli_test_file_repo"
4343
test "$(echo "$OUTPUT" | jq -r '.|length')" = "6"
4444

45+
# retain_checkpoints was added to Repository in pulpcore 3.106.0 (pulp/pulpcore#7428)
46+
if pulp debug has-plugin --name "core" --specifier ">=3.106.0"
47+
then
48+
expect_succ pulp file repository update --repository "cli_test_file_repo" --retain-checkpoints 5
49+
expect_succ pulp file repository show --repository "cli_test_file_repo"
50+
test "$(echo "$OUTPUT" | jq -r '.retain_checkpoints')" = "5"
51+
expect_succ pulp file repository update --repository "cli_test_file_repo" --retain-checkpoints ""
52+
expect_succ pulp file repository show --repository "cli_test_file_repo"
53+
test "$(echo "$OUTPUT" | jq -r '.retain_checkpoints')" = "null"
54+
fi
55+
4556
if pulp debug has-plugin --name "file" --specifier ">=1.7.0"
4657
then
4758
expect_succ pulp file repository update --repository "cli_test_file_repo" --manifest "manifest.csv"

tests/scripts/pulp_rpm/test_rpm_sync_publish.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ expect_succ pulp rpm repository update --repository "cli_test_rpm_sync_repositor
3636
expect_succ pulp rpm repository show --repository "cli_test_rpm_sync_repository"
3737
test "$(echo "$OUTPUT" | jq -r '.description')" = "null"
3838

39+
# retain_checkpoints was added to Repository in pulpcore 3.106.0 (pulp/pulpcore#7428)
40+
if pulp debug has-plugin --name "core" --specifier ">=3.106.0"
41+
then
42+
expect_succ pulp rpm repository update --repository "cli_test_rpm_sync_repository" --retain-checkpoints 5
43+
expect_succ pulp rpm repository show --repository "cli_test_rpm_sync_repository"
44+
test "$(echo "$OUTPUT" | jq -r '.retain_checkpoints')" = "5"
45+
expect_succ pulp rpm repository update --repository "cli_test_rpm_sync_repository" --retain-checkpoints ""
46+
expect_succ pulp rpm repository show --repository "cli_test_rpm_sync_repository"
47+
test "$(echo "$OUTPUT" | jq -r '.retain_checkpoints')" = "null"
48+
fi
49+
3950
# sqlite metadata removal from pulp_rpm (pulp/pulp_rpm#3328)
4051
if pulp debug has-plugin --name "rpm" --specifier "<3.25.0"
4152
then

0 commit comments

Comments
 (0)