-
Notifications
You must be signed in to change notification settings - Fork 84
[PULP-1496] Add repository-specific package blocklist #1187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jobselko
wants to merge
1
commit into
pulp:main
Choose a base branch
from
jobselko:1166
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Added repository-specific package blocklist. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # Package Blocklist | ||
|
|
||
| A repository can have a blocklist that prevents specific packages from being added. | ||
| Blocklist entries can match by package `name` (all versions), package `name` with an exact `version`, or exact `filename`. | ||
| Exactly one of `name` or `filename` must be provided. | ||
|
|
||
| Each entry records the PRN of the user who created it in the `added_by` field. | ||
|
|
||
| ## Setup | ||
|
|
||
| If you do not already have a repository, create one: | ||
|
|
||
| ```bash | ||
| pulp python repository create --name foo | ||
| ``` | ||
|
|
||
| Set the API base URL and repository HREF for use in the subsequent commands: | ||
|
|
||
| ```bash | ||
| PULP_API="http://localhost:5001" | ||
| REPO_HREF=$(pulp python repository show --name foo | jq -r ".pulp_href") | ||
| ``` | ||
|
|
||
| ## Add a blocklist entry | ||
|
|
||
| === "By name (all versions)" | ||
|
|
||
| ```bash | ||
| # Block all versions of shelf-reader | ||
| http POST "${PULP_API}${REPO_HREF}blocklist_entries/" name="shelf-reader" | ||
| ``` | ||
|
|
||
| === "By name and version" | ||
|
|
||
| ```bash | ||
| # Block only shelf-reader 0.1 | ||
| http POST "${PULP_API}${REPO_HREF}blocklist_entries/" name="shelf-reader" version="0.1" | ||
| ``` | ||
|
|
||
| === "By filename" | ||
|
|
||
| ```bash | ||
| # Block only shelf-reader-0.1.tar.gz | ||
| http POST "${PULP_API}${REPO_HREF}blocklist_entries/" filename="shelf-reader-0.1.tar.gz" | ||
| ``` | ||
|
|
||
| Set the UUID of a created entry for use in the subsequent commands: | ||
|
|
||
| ```bash | ||
| ENTRY_UUID=$(http GET "${PULP_API}${REPO_HREF}blocklist_entries/" | jq -r '.results[0].prn | split(":") | .[-1]') | ||
| ``` | ||
|
|
||
| ## List blocklist entries | ||
|
|
||
| List all entries for a repository: | ||
|
|
||
| ```bash | ||
| http GET "${PULP_API}${REPO_HREF}blocklist_entries/" | ||
| ``` | ||
|
|
||
| Show a single entry: | ||
|
|
||
| ```bash | ||
| http GET "${PULP_API}${REPO_HREF}blocklist_entries/${ENTRY_UUID}/" | ||
| ``` | ||
|
|
||
| ## Remove a blocklist entry | ||
|
|
||
| ```bash | ||
| http DELETE "${PULP_API}${REPO_HREF}blocklist_entries/${ENTRY_UUID}/" | ||
| ``` | ||
|
|
||
| Once an entry is removed, packages matching it can be added to the repository again. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Generated by Django 5.2.10 on 2026-04-16 14:00 | ||
|
|
||
| import django.db.models.deletion | ||
| import django_lifecycle.mixins | ||
| import pulpcore.app.models.base | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("python", "0021_pythonrepository_upload_duplicate_filenames"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name="PythonBlocklistEntry", | ||
| fields=[ | ||
| ( | ||
| "pulp_id", | ||
| models.UUIDField( | ||
| default=pulpcore.app.models.base.pulp_uuid, | ||
| editable=False, | ||
| primary_key=True, | ||
| serialize=False, | ||
| ), | ||
| ), | ||
| ("pulp_created", models.DateTimeField(auto_now_add=True)), | ||
| ("pulp_last_updated", models.DateTimeField(auto_now=True, null=True)), | ||
| ("name", models.TextField(default=None, null=True)), | ||
| ("version", models.TextField(default=None, null=True)), | ||
| ("filename", models.TextField(default=None, null=True)), | ||
| ("added_by", models.TextField(default="")), | ||
| ( | ||
| "repository", | ||
| models.ForeignKey( | ||
| on_delete=django.db.models.deletion.CASCADE, | ||
| related_name="blocklist_entries", | ||
| to="python.pythonrepository", | ||
| ), | ||
| ), | ||
| ], | ||
| options={ | ||
| "default_related_name": "%(app_label)s_%(model_name)s", | ||
| }, | ||
| bases=(django_lifecycle.mixins.LifecycleModelMixin, models.Model), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.