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 2 commits into
Conversation
Add a default_content_guard field to the Domain model that is automatically assigned to new distributions created within the domain when they do not specify their own content guard. Use a composite content guard as the default to apply multiple guards. Closes: pulp#7988 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0521ec5 to
f3d180c
Compare
Document the default_content_guard feature in the domain creation guide and content protection guide, covering setup, composite guards as defaults, and removal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
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. |
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