Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/2139.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added pulp_labels field to ContainerNamespace for labeling and organizing namespaces
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.2.6 on 2026-01-27 00:00

from django.contrib.postgres.fields import HStoreField
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('container', '0046_alter_manifest_listed_manifests'),
]

operations = [
migrations.AddField(
model_name='containernamespace',
name='pulp_labels',
field=HStoreField(default=dict),
),
]
3 changes: 3 additions & 0 deletions pulp_container/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.db import models
from django.conf import settings
from django.contrib.postgres import fields
from django.contrib.postgres.fields import HStoreField
from django.shortcuts import redirect
from django_lifecycle import hook, AFTER_CREATE, AFTER_DELETE, AFTER_UPDATE

Expand Down Expand Up @@ -438,10 +439,12 @@ class ContainerNamespace(BaseModel, AutoAddObjPermsMixin):

Fields:
name (models.TextField): The name of the namespace.
pulp_labels (HStoreField): Key-value pairs for labeling and organizing namespaces.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was on BaseModel, but apparently not. Do you remember why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original implementation before it was a HStoreField was on BaseModel. That was removed a long time ago for performance reasons. Why we switched to just adding HStoreField to each model individually I don't remember.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the joins across master-detail were an issue

"""

name = models.TextField(db_index=True)
pulp_domain = models.ForeignKey("core.Domain", default=get_domain_pk, on_delete=models.PROTECT)
pulp_labels = HStoreField(default=dict)

class Meta:
unique_together = ("name", "pulp_domain")
Expand Down
4 changes: 3 additions & 1 deletion pulp_container/app/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
RepositoryVersionRelatedField,
SingleArtifactContentSerializer,
ValidateFieldsMixin,
pulp_labels_validator,
)
from pulpcore.plugin.util import get_domain

Expand Down Expand Up @@ -241,9 +242,10 @@ class ContainerNamespaceSerializer(ModelSerializer, GetOrCreateSerializerMixin):
"""

pulp_href = IdentityField(view_name="pulp_container/namespaces-detail")
pulp_labels = serializers.HStoreField(required=False, validators=[pulp_labels_validator])

class Meta:
fields = ModelSerializer.Meta.fields + ("name",)
fields = ModelSerializer.Meta.fields + ("name", "pulp_labels")
model = models.ContainerNamespace


Expand Down