Skip to content

Commit a98d2cd

Browse files
committed
Add allow_package_substitution to Python repos
closes #1375 Assisted By: Claude Opus 4.6
1 parent e0a278f commit a98d2cd

5 files changed

Lines changed: 21 additions & 0 deletions

File tree

CHANGES/1375.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added `--allow-package-substitution`/`--block-package-substitution` options to `pulp python repository` for controlling packages with same filenames but different checksums.

CHANGES/pulp-glue/1375.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added `allow_package_substitution` field to `PulpPythonRepositoryContext` for `pulp_python>=3.28.0`.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> En
158158
body = super().preprocess_entity(body, partial=partial)
159159
if "autopublish" in body:
160160
self.pulp_ctx.needs_plugin(PluginRequirement("python", specifier=">=3.3.0"))
161+
if "allow_package_substitution" in body:
162+
self.pulp_ctx.needs_plugin(PluginRequirement("python", specifier=">=3.28.0"))
161163
return body
162164

163165
def repair_metadata(self) -> t.Any:

src/pulpcore/cli/python/repository.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ def repository() -> None:
8080
needs_plugins=[PluginRequirement("python", specifier=">=3.3.0")],
8181
default=None,
8282
),
83+
pulp_option(
84+
"--allow-package-substitution/--block-package-substitution",
85+
needs_plugins=[PluginRequirement("python", specifier=">=3.28.0")],
86+
default=None,
87+
help=_(
88+
"Allow replacing existing packages with packages of the same filename but"
89+
" different checksum. When blocked, such operations are rejected."
90+
),
91+
),
8392
retained_versions_option,
8493
pulp_labels_option,
8594
]

tests/scripts/pulp_python/test_repository.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,12 @@ if pulp debug has-plugin --name "python" --specifier ">=3.26.0"; then
3737
expect_succ test "$(echo "$OUTPUT" | jq -r '.state')" = "completed"
3838
fi
3939

40+
if pulp debug has-plugin --name "python" --specifier ">=3.28.0"; then
41+
expect_succ pulp python repository show --repository "cli_test_python_repo"
42+
expect_succ test "$(echo "$OUTPUT" | jq -r '.allow_package_substitution')" = "true"
43+
expect_succ pulp python repository update --repository "cli_test_python_repo" --block-package-substitution
44+
expect_succ pulp python repository show --repository "cli_test_python_repo"
45+
expect_succ test "$(echo "$OUTPUT" | jq -r '.allow_package_substitution')" = "false"
46+
fi
47+
4048
expect_succ pulp python repository destroy --name "cli_test_python_repo"

0 commit comments

Comments
 (0)