1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/olmv1-catalog-selection-by-labels-or-expressions.adoc
2025-02-20 02:56:57 +00:00

81 lines
2.4 KiB
Plaintext

// Module included in the following assemblies:
// * extensions/catalogs/olmv1-catalog-content-resolution.adoc
:_mod-docs-content-type: REFERENCE
[id="olmv1-catalog-selection-by-labels-or-exp_{context}"]
= Catalog selection by labels or expressions
You can add metadata to a catalog by using labels in the custom resource (CR) of a cluster catalog. You can then filter catalog selection by specifying the assigned labels or using expressions in the CR of the cluster extension.
The following cluster catalog CR adds the `example.com/support` label with the value of `true` to the `catalog-a` cluster catalog:
.Example cluster catalog CR with labels
[source,yaml]
----
apiVersion: olm.operatorframework.io/v1
kind: ClusterCatalog
metadata:
name: catalog-a
labels:
example.com/support: "true"
spec:
source:
type: Image
image:
ref: quay.io/example/content-management-a:latest
----
The following cluster extension CR uses the `matchLabels` selector to select catalogs with the `example.com/support` label and the value of `true`:
.Example cluster extension CR with `matchLabels` selector
[source,yaml]
----
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: <example_extension>
spec:
namespace: <example_namespace>
serviceAccount:
name: <example_extension>-installer
source:
sourceType: Catalog
catalog:
packageName: <example_extension>-operator
selector:
matchLabels:
example.com/support: "true"
----
You can use the `matchExpressions` field to perform more complex filtering for labels. The following cluster extension CR selects catalogs with the `example.com/support` label and a value of `production` or `supported`:
.Example cluster extension CR with `matchExpression` selector
[source,yaml]
----
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: <example_extension>
spec:
namespace: <example_namespace>
serviceAccount:
name: <example_extension>-installer
source:
sourceType: Catalog
catalog:
packageName: <example_extension>-operator
selector:
matchExpressions:
- key: example.com/support
operator: In
values:
- "production"
- "supported"
----
[NOTE]
====
If you use both the `matchLabels` and `matchExpressions` fields, the selected catalog must satisfy all specified criteria.
====