Skip to content

Commit cd8d7a0

Browse files
committed
Add docs for package policies
Assisted By: Claude Opus 4.6
1 parent 760a28a commit cd8d7a0

3 files changed

Lines changed: 96 additions & 74 deletions

File tree

docs/user/guides/_SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
* [Host Python Content](host.md)
55
* [Vulnerability Report](vulnerability_report.md)
66
* [Attestation Hosting](attestation.md)
7-
* [Package Blocklist](blocklist.md)
7+
* [Package Policies](package_policies.md)

docs/user/guides/blocklist.md

Lines changed: 0 additions & 73 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Package Policies
2+
3+
Python repositories offer two mechanisms for controlling which packages they accept:
4+
**blocklists** to prevent specific packages from being added, and
5+
**package substitution control** to prevent silent replacement of existing packages.
6+
7+
## Setup
8+
9+
If you do not already have a repository, create one:
10+
11+
```bash
12+
pulp python repository create --name foo
13+
```
14+
15+
## Package Blocklist
16+
17+
A repository can have a blocklist that prevents specific packages from being added.
18+
Blocklist entries can match by package `name` (all versions), package `name` with an exact `version`, or exact `filename`.
19+
Exactly one of `name` or `filename` must be provided.
20+
21+
Each entry records the PRN of the user who created it in the `added_by` field.
22+
23+
### Add a blocklist entry
24+
25+
=== "By name (all versions)"
26+
27+
```bash
28+
# Block all versions of shelf-reader
29+
pulp python repository blocklist add --repository "foo" --name "shelf-reader"
30+
```
31+
32+
=== "By name and version"
33+
34+
```bash
35+
# Block only shelf-reader 0.1
36+
pulp python repository blocklist add --repository "foo" --name "shelf-reader" --version "0.1"
37+
```
38+
39+
=== "By filename"
40+
41+
```bash
42+
# Block only shelf-reader-0.1.tar.gz
43+
pulp python repository blocklist add --repository "foo" --filename "shelf-reader-0.1.tar.gz"
44+
```
45+
46+
### List blocklist entries
47+
48+
List all entries for a repository:
49+
50+
```bash
51+
pulp python repository blocklist list --repository "foo"
52+
```
53+
54+
Show a single entry:
55+
56+
```bash
57+
pulp python repository blocklist show --repository "foo" --name "shelf-reader" --version "0.1"
58+
```
59+
60+
### Remove a blocklist entry
61+
62+
```bash
63+
pulp python repository blocklist remove --repository "foo" --name "shelf-reader" --version "0.1"
64+
```
65+
66+
Once an entry is removed, packages matching it can be added to the repository again.
67+
68+
## Package Substitution
69+
70+
By default, Python repositories allow package substitution: uploading, syncing, or adding a package
71+
with the same filename as an existing package but a different checksum will silently replace it.
72+
73+
This behavior is controlled by the `allow_package_substitution` field on a Python repository.
74+
When set to `False`, any operation (upload, sync, or modify) that would replace an existing package with a different checksum is rejected.
75+
Re-adding a package with the same filename *and* the same checksum is always accepted (idempotent).
76+
77+
### Disable package substitution
78+
79+
```bash
80+
pulp python repository update --repository "foo" --block-package-substitution
81+
```
82+
83+
You can also set this when creating a repository:
84+
85+
```bash
86+
pulp python repository create --name "foo2" --block-package-substitution
87+
```
88+
89+
### Re-enable package substitution
90+
91+
```bash
92+
pulp python repository update --repository "foo" --allow-package-substitution
93+
```
94+
95+
Once re-enabled, packages with duplicate filenames can replace existing content again.

0 commit comments

Comments
 (0)