Story #8067
closedStory #7127: Add object labels
As a user, I can filter resources by labels
100%
Updated by daviddavis almost 4 years ago
We're supporting k8s style label selectors. To give an example of a possible label search: ?labelSelector=environment%3Dproduction,tier%3Dfrontend
(which represents environment=production,tier=frontend
)
k8s limits labels to alphanumeric characters but our stakeholders have asked to be able to use any char. The one problem I foresee is that there are special characters (e.g. ,
) that will be a problem for the label selector if the label contains these characters.
We're already using urlencoding to unescape the search selector string so we can't use that the escape/unescape characters. The two options I see:
- Add docs informing users if they want to search by a label, they should stick to labels with alphanumeric chars (easy)
- Escape these characters some other way?
Updated by daviddavis almost 4 years ago
During open floor today, we agreed to forbid characters that would cause problems with the label filter. I think this would specifically mean ,
and )
.
Updated by daviddavis almost 4 years ago
I looked at some alternative methods for filtering. It looks like there was a discussion in the django-filter project about having dynamic filters for json fields. The problem is that any such solution be openapi compatible or work with our bindings.
Updated by bmbouter almost 4 years ago
@daviddavis so for the current separate table and GenericForeignKey implementation how do users add a key/value, change, and remove a key/value?
Also for the current separate table with GenericForeignKey implementation, does built-in filtering provide any functionality?
Updated by daviddavis almost 4 years ago
bmbouter wrote:
@daviddavis so for the current separate table and GenericForeignKey implementation how do users add a key/value, change, and remove a key/value?
It's just a DictField
. The code is pretty basic. There are example API calls in the epic/parent task of this issue. And here's the PR with some tests: https://github.com/pulp/pulpcore/pull/1070
Also for the current separate table with GenericForeignKey implementation, does built-in filtering provide any functionality?
So you get pulp_labels__key
and pulp_labels__value
along with the other filters like pulp_labels__key__contains
, etc.
Updated by daviddavis almost 4 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to daviddavis
Updated by pulpbot almost 4 years ago
- Status changed from ASSIGNED to POST
Added by daviddavis almost 4 years ago
Updated by daviddavis almost 4 years ago
- Status changed from POST to MODIFIED
- % Done changed from 0 to 100
Applied in changeset pulpcore|348c654567067fb24bc13fa5105628433fb911fb.
Updated by pulpbot almost 4 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Add pulp_label_filter for filtering by pulp_labels
fixes #8067