diff --git a/CHANGES/+error-on-reject.feature b/CHANGES/+error-on-reject.feature new file mode 100644 index 000000000..816cb6ae5 --- /dev/null +++ b/CHANGES/+error-on-reject.feature @@ -0,0 +1 @@ +Added `--error-on-reject`/`--no-error-on-reject` options to `pulp python repository`. diff --git a/pulp-glue/src/pulp_glue/python/context.py b/pulp-glue/src/pulp_glue/python/context.py index d1f8dce38..f576149f4 100644 --- a/pulp-glue/src/pulp_glue/python/context.py +++ b/pulp-glue/src/pulp_glue/python/context.py @@ -134,6 +134,8 @@ def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> En body = super().preprocess_entity(body, partial=partial) if "allow_package_substitution" in body: self.pulp_ctx.needs_plugin(PluginRequirement("python", specifier=">=3.28.0")) + if "error_on_reject" in body: + self.pulp_ctx.needs_plugin(PluginRequirement("python", specifier=">=3.34.0")) return body def repair_metadata(self) -> t.Any: diff --git a/src/pulpcore/cli/python/repository.py b/src/pulpcore/cli/python/repository.py index f8d958f66..5322e3914 100644 --- a/src/pulpcore/cli/python/repository.py +++ b/src/pulpcore/cli/python/repository.py @@ -91,6 +91,16 @@ def repository() -> None: " different checksum. When blocked, such operations are rejected." ), ), + pulp_option( + "--error-on-reject/--no-error-on-reject", + needs_plugins=[PluginRequirement("python", specifier=">=3.34.0")], + default=None, + help=_( + "Fail the entire repository version when packages are rejected by the" + " package substitution or blocklist policies. When disabled, rejected" + " packages are skipped and remaining packages are added." + ), + ), retained_versions_option, pulp_labels_option, ] diff --git a/tests/scripts/pulp_python/test_repository.sh b/tests/scripts/pulp_python/test_repository.sh index f1a60b4e6..273198c34 100755 --- a/tests/scripts/pulp_python/test_repository.sh +++ b/tests/scripts/pulp_python/test_repository.sh @@ -45,4 +45,12 @@ if pulp debug has-plugin --name "python" --specifier ">=3.28.0"; then expect_succ test "$(echo "$OUTPUT" | jq -r '.allow_package_substitution')" = "false" fi +if pulp debug has-plugin --name "python" --specifier ">=3.34.0"; then + expect_succ pulp python repository show --repository "cli_test_python_repo" + expect_succ test "$(echo "$OUTPUT" | jq -r '.error_on_reject')" = "true" + expect_succ pulp python repository update --repository "cli_test_python_repo" --no-error-on-reject + expect_succ pulp python repository show --repository "cli_test_python_repo" + expect_succ test "$(echo "$OUTPUT" | jq -r '.error_on_reject')" = "false" +fi + expect_succ pulp python repository destroy --name "cli_test_python_repo"