1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-07 00:48:01 +01:00
Files
openshift-docs/modules/olmv1-version-range-comparisons.adoc
2025-02-20 17:03:44 -05:00

141 lines
2.9 KiB
Plaintext

// Module included in the following assemblies:
//
// * operators/olm_v1/olmv1-installing-an-operator-from-a-catalog.adoc
:_mod-docs-content-type: REFERENCE
[id="olmv1-version-range-comparisons_{context}"]
= Version comparison strings
You can define a version range by adding a comparison string to the `spec.version` field in an Operator or extension's custom resource (CR). A comparison string is a list of space- or comma-separated values and one or more comparison operators enclosed in double quotation marks (`"`). You can add another comparison string by including an `OR`, or double vertical bar (`||`), comparison operator between the strings.
.Basic comparisons
[options="header"]
|===
|Comparison operator |Definition
|`=`
|Equal to
|`!=`
|Not equal to
|`>`
|Greater than
| `<`
|Less than
|`>=`
|Greater than or equal to
|`\<=`
|Less than or equal to
|===
You can specify a version range in an Operator or extension's CR by using a range comparison similar to the following example:
.Example version range comparison
[source,yaml]
----
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: <clusterextension_name>
spec:
namespace: <installed_namespace>
serviceAccount:
name: <service_account_installer_name>
source:
sourceType: Catalog
catalog:
packageName: <package_name>
version: ">=1.11, <1.13"
----
You can use wildcard characters in all types of comparison strings. {olmv1} accepts `x`, `X`, and asterisks (`*`) as wildcard characters. When you use a wildcard character with the equal sign (`=`) comparison operator, you define a comparison at the patch or minor version level.
.Example wildcard characters in comparison strings
[options="header"]
|===
|Wildcard comparison |Matching string
|`1.11.x`
|`>=1.11.0, <1.12.0`
|`>=1.12.X`
|`>=1.12.0`
|`\<=2.x`
|`<3`
|`*`
|`>=0.0.0`
|===
You can make patch release comparisons by using the tilde (`~`) comparison operator. Patch release comparisons specify a minor version up to the next major version.
.Example patch release comparisons
[options="header"]
|===
|Patch release comparison |Matching string
|`~1.11.0`
|`>=1.11.0, <1.12.0`
|`~1`
|`>=1, <2`
|`~1.12`
|`>=1.12, <1.13`
|`~1.12.x`
|`>=1.12.0, <1.13.0`
|`~1.x`
|`>=1, <2`
|===
You can use the caret (`^`) comparison operator to make a comparison for a major release. If you make a major release comparison before the first stable release is published, the minor versions define the API's level of stability. In the semantic versioning (semver) specification, the first stable release is published as the `1.0.0` version.
.Example major release comparisons
[options="header"]
|===
|Major release comparison |Matching string
|`^0`
|`>=0.0.0, <1.0.0`
|`^0.0`
|`>=0.0.0, <0.1.0`
|`^0.0.3`
|`>=0.0.3, <0.0.4`
|`^0.2`
|`>=0.2.0, <0.3.0`
|`^0.2.3`
|`>=0.2.3, <0.3.0`
|`^1.2.x`
|`>= 1.2.0, < 2.0.0`
|`^1.2.3`
|`>= 1.2.3, < 2.0.0`
|`^2.x`
|`>= 2.0.0, < 3`
|`^2.3`
|`>= 2.3, < 3`
|===