Background/requirements: https://pulp.plan.io/issues/7127
Labels can be filtered by passing a urlencoded string to a label_selector
parameter.
Some examples based on the kubernetes documentation:
?label_selector=environment%3Dproduction,tier%3Dfrontend
environment=production,tier=frontend
?label_selector=environment+in+%28production%2Cqa%29%2Ctier+in+%28frontend%29
environment in (production,qa),tier in (frontend)
Note: Ansible Galaxy and RHUI have agreed that for a first pass, we could just support a subset of operators (ie =
and !=
).
LabelSelectFilter
would be a django_filter.Filter
that parses the label_select parameter and then filters the queryset. It can be applied to a Queryset of any model with labels.
Note: for an example of a complex Filter
, see the RepositoryVersionFilter
.
Create a new LabelSerializer
that can be nested into other model serializers as a field (much like the CreatedResourceSerializer
). This serializer should be both readable and writable and should enable the following API calls.
# GET /pulp/api/v3/repositories/file/file/
{
...
"labels": {"foo": "bar", "foo2": "baz"},
...
}
# POST /pulp/api/v3/repositories/file/file/ name=test labels='[{"foo": "bar"}]'
{
...
"labels": {"foo": "bar"},
...
}
# PUT /pulp/api/v3/repositories/file/file/<uuid>/ labels='[{"foo": "baz"}]'
{
...
"labels": {"foo": "baz"},
...
}
This design uses a set of labels that are shared across resources.
Label
tableConstraints
Label
key and value are unique togetherResourceLabel
resource and label are unique togetherOne challenge would be dealing with orphaned labels. Either the label would persist after it's been orphaned or we'd have to cleanup labels as they get orphaned. For the latter, we'd need to catch the case that the label doesn't exist when associating it and if so, create it.
This design uses a map object that stores the resource's labels as an hstore. It is a one-to-one relationship.
Constraints
One challenge is when to create the ResourceLabelMap
. Would we create it with the resource? Or when a label is first set? Also, not sure about hstore performance when filtering.
Instead of using generic foreign keys to relate tags or data mappings to remotes, repositories, etc, we could relate the remotes, repos, repoversions, publications, distributions to a common "resource" object that holds the tags. The direct relationships would make queries easier and more performant, and avoid invalid data that is endemic to GFKs.
Additionally the Resource model can be used to replace CreatedResources and potentially resolve https://pulp.plan.io/issues/6496
I haven't really looked into it but maybe it could be used to simplify task resource locking as well, and eliminate one of those models.
The easiest way to implement this is another level of multi-table inheritance. Since all of our models are already "paying the cost" of multi-table inheritance, there isn't much real downside in terms of usability.
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing