Project

Profile

Help

Story #8067

closed

Story #7127: Add object labels

As a user, I can filter resources by labels

Added by daviddavis almost 4 years ago. Updated almost 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
% Done:

100%

Estimated time:
Platform Release:
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:
Actions #1

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?
Actions #2

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 ).

Actions #3

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.

Actions #4

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?

Actions #5

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.

Actions #6

Updated by daviddavis almost 4 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to daviddavis
Actions #7

Updated by daviddavis almost 4 years ago

  • Sprint/Milestone set to 3.10.0
Actions #8

Updated by pulpbot almost 4 years ago

  • Status changed from ASSIGNED to POST

Added by daviddavis almost 4 years ago

Revision 348c6545 | View on GitHub

Add pulp_label_filter for filtering by pulp_labels

fixes #8067

Actions #9

Updated by daviddavis almost 4 years ago

  • Status changed from POST to MODIFIED
  • % Done changed from 0 to 100
Actions #10

Updated by pulpbot almost 4 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF