Add default content guard auto-assignment for distributions within a domain - #7992
Add default content guard auto-assignment for distributions within a domain#7992dkliban wants to merge 1 commit into
Conversation
0521ec5 to
f3d180c
Compare
|
Setting aside the precise implementation, is the goal actually to assign a default value for the content guard, or is it to protect content by default with a certain guard? Those are slightly different things - in the latter case, maybe you would leave the default value on the distribution null, but null would be remapped to a globally default content guard implicitly. The semantics are different, in the former case changing the default content guard wouldn't change any distributions, they would need to be updated manually, whereas in the latter case all distributions left in a default state would be remapped to a different content guard. |
|
@dralley you bring up a good question. explicitly setting the content guard on a distribution should make it easier to debug any issues when a user is having issues with accessing content. |
|
Fixed — switched to single backticks in the changelog entry. |
25ea583 to
833adc2
Compare
833adc2 to
b7a0c47
Compare
b7a0c47 to
27faacb
Compare
| redirect_to_object_storage = models.BooleanField(default=True) | ||
| hide_guarded_distributions = models.BooleanField(default=False) | ||
| default_content_guard = models.ForeignKey( | ||
| "ContentGuard", null=True, on_delete=models.SET_NULL, related_name="+" |
There was a problem hiding this comment.
related_name="+" is Django's convention for suppressing the reverse accessor entirely. Without it, Django would create content_guard.domain_set (or similar) pointing back to domains — a second traversal path that would be unused and confusing since ContentGuard already has its own pulp_domain FK for that. The + keeps the FK without polluting the ContentGuard namespace with an accessor nobody would call.
27faacb to
d482dd1
Compare
|
@dkliban Formatting |
d482dd1 to
ff4b8b0
Compare
Adds a `default_content_guard` field to the Domain model. When a distribution is created within a domain that has a `default_content_guard` set and the distribution does not specify its own content guard, the domain's default is automatically assigned. An explicitly provided content guard always takes precedence. Changes: - Domain.default_content_guard FK (nullable, on_delete=SET_NULL) + migration - Distribution BEFORE_CREATE hook auto-assigns the domain default - DomainSerializer exposes the field with cross-domain validation - DomainViewSet select_related to avoid N+1 on list Closes: pulp#7988 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ff4b8b0 to
2d350c4
Compare
|
Fixed the CI failure in . The domain deletion task was failing because |
Summary
Adds a
default_content_guardfield to the Domain model. When a distribution is created within a domain that has adefault_content_guardset and the distribution does not specify its own content guard, the domain's default is automatically assigned. To apply multiple guards by default, set a composite content guard as the domain'sdefault_content_guard.Changes
Domain.default_content_guardforeign key (nullable, on_delete=SET_NULL) + migrationDistributionBEFORE_CREATE hook auto-assigns the domain default when no guard is specified (an explicit content guard always wins)DomainSerializerexposes the field (plus a_prnconvenience field) and validates that the guard belongs to the same domainDomainViewSetselect_related to avoid N+1 on listTests
Closes: #7988
🤖 Generated with Claude Code