Resource Labels
A resource label is a simple, arbitrary key-value structure that we can use to enrich resources. You can use labels for things like categorization, resource grouping, and marking federated resources.
-
Users
-
Roles
-
Compose namespace
-
Compose page
-
Compose chart
-
Compose module
-
Compose module field
-
Compose record
Core logic
Resource labels are flexible and compatible with any Corteza resource.
However, if we want a resource to use resource labels, it must conform to the pkg/label.LabeledResource interface.
The core logic that works with the centralized label store is implemented in a dedicated package (pkg/label).
Therefore, services can trivially include the package into the request cycle.
|
Use the system/user ( |
pkg/label/types.Label):Label struct {
// Kind of the labelled resource
Kind string
// ID of the labelled resource
ResourceID uint64
// Other parameters
// ...
}
|
Resource labels define a simple key-value structure to simplify the underlying logic for label management. The simple structure also helps us not to abuse the feature. |
Resource label structure
key: value structure:key-
The label key is a simple
stringthat is limited to 512 characters. Keys are unique per specific resources (a resource can have a single value for the givenkey).
|
The |
value-
The label values is a regular
stringvalue with no other constraints.
Assigning labels
label is provided, the resource must support the following cases:-
If the
labelparameter is empty, remove all labels from the given resource. -
If the
labelparameter is not empty, remove missing labels and add new labels.
If the label parameter is not provided, no modifications are performed.
Retrieving resources
-
Existence filter: collect the resources where the key exists.
-
!Existence filter: collect the resources where the key does not exist.
-
Key-value filter: collect the resources where the key exists and the value matches.
Access control
Label access control is inherited from resource access control; resource labels do not put any additional access control.
-
Read access inherits the resource’s
readoperation. -
Create access inherits the resource’s
createoperation. -
Update access inherits the resource’s
updateoperation. -
Delete access inherits the resource’s
deleteoperation.