Resource labelling
A resource label is a simple, arbitrary key-value structure, that we can use to enrich Corteza resources. Labels can be used for things like Categorization, resource grouping, data migration references, and marking federated resources.
-
Users
-
Roles
-
Compose namespace
-
Compose page
-
Compose chart
-
Compose module
-
Compose module field
-
Compose record
|
Corteza Messaging resources will not support resource labeling. |
Core logic
Resource labels are flexible and compatible with any Corteza resource.
If we want a resource to be able 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).
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-
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 inherits from resource access control; resource labels do not put in place 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.