From 97bf635908760f05e6c549effa7e8342ad93003a Mon Sep 17 00:00:00 2001 From: Mikalai Radchuk Date: Thu, 14 Nov 2024 12:00:32 +0100 Subject: [PATCH] Change formatting in the "Catalog queries" doc This commit adds definition lists for placeholders such as ``. The goal of adding definition lists for placeholders is to improve their visibility in the code snippets. This commit also switches existing definition lists [1] (list of queries) to unordered list. The current list of queries uses definition lists from mkdocs-material. However it relies on a tailing space after a colon to work. E.g. the whole line becomes `: ` and it is prone to errors because: 1. It is easy to overlook a space which is part of markdown. 2. Many editors remove tailing spaces at the end of lines. 3. We are adding more definition lists into this docs to explain placeholders such as ``. With nested definition lists markdown of this document going to be very difficult to manage. [1]: https://squidfunk.github.io/mkdocs-material/reference/lists/#using-definition-lists Signed-off-by: Mikalai Radchuk --- docs/howto/catalog-queries.md | 127 ++++++++++++++++++++++------------ 1 file changed, 81 insertions(+), 46 deletions(-) diff --git a/docs/howto/catalog-queries.md b/docs/howto/catalog-queries.md index c58a7bff1..91314acdd 100644 --- a/docs/howto/catalog-queries.md +++ b/docs/howto/catalog-queries.md @@ -1,73 +1,108 @@ # Catalog queries +After you [add a catalog of extensions](../tutorials/add-catalog.md) to your cluster, you must port forward your catalog as a service. +Then you can query the catalog by using `curl` commands and the `jq` CLI tool to find extensions to install. + +## Prerequisites + +* You have added a ClusterCatalog of extensions, such as [OperatorHub.io](https://operatorhub.io), to your cluster. +* You have installed the `jq` CLI tool. + !!! note By default, Catalogd is installed with TLS enabled for the catalog webserver. The following examples will show this default behavior, but for simplicity's sake will ignore TLS verification in the curl commands using the `-k` flag. +You also need to port forward the catalog server service: + +``` terminal +kubectl -n olmv1-system port-forward svc/catalogd-service 8443:443 +``` -You can use the `curl` command with `jq` to query catalogs that are installed on your cluster. +Now you can use the `curl` command with `jq` to query catalogs that are installed on your cluster. ``` terminal title="Query syntax" curl -k https://localhost:8443/catalogs/operatorhubio/api/v1/all | ``` +`` +: One of the `jq` queries from this document ## Package queries -Available packages in a catalog -: -``` terminal -jq -s '.[] | select( .schema == "olm.package")' -``` +* Available packages in a catalog: + ``` terminal + jq -s '.[] | select( .schema == "olm.package")' + ``` -Packages that support `AllNamespaces` install mode and do not use webhooks +* Packages that support `AllNamespaces` install mode and do not use webhooks: + ``` terminal + jq -c 'select(.schema == "olm.bundle") | {"package":.package, "version":.properties[] | select(.type == "olm.bundle.object").value.data | @base64d | fromjson | select(.kind == "ClusterServiceVersion" and (.spec.installModes[] | select(.type == "AllNamespaces" and .supported == true) != null) and .spec.webhookdefinitions == null).spec.version}' + ``` -: -``` terminal -jq -c 'select(.schema == "olm.bundle") | {"package":.package, "version":.properties[] | select(.type == "olm.bundle.object").value.data | @base64d | fromjson | select(.kind == "ClusterServiceVersion" and (.spec.installModes[] | select(.type == "AllNamespaces" and .supported == true) != null) and .spec.webhookdefinitions == null).spec.version}' -``` +* Package metadata: + ``` terminal + jq -s '.[] | select( .schema == "olm.package") | select( .name == "")' + ``` -Package metadata -: -``` terminal -jq -s '.[] | select( .schema == "olm.package") | select( .name == "")' -``` + `` + : Name of the package from the catalog you are querying. -Catalog blobs in a package -: -``` terminal -jq -s '.[] | select( .package == "")' -``` +* Catalog blobs in a package: + ``` terminal + jq -s '.[] | select( .package == "")' + ``` + + `` + : Name of the package from the catalog you are querying. ## Channel queries -Channels in a package -: -``` terminal -jq -s '.[] | select( .schema == "olm.channel" ) | select( .package == "") | .name' -``` +* Channels in a package: + ``` terminal + jq -s '.[] | select( .schema == "olm.channel" ) | select( .package == "") | .name' + ``` -Versions in a channel -: -``` terminal -jq -s '.[] | select( .package == "" ) | select( .schema == "olm.channel" ) | select( .name == "" ) | .entries | .[] | .name' -``` + `` + : Name of the package from the catalog you are querying. -Latest version in a channel and upgrade path -: -``` terminal -jq -s '.[] | select( .schema == "olm.channel" ) | select ( .name == "") | select( .package == "")' -``` +* Versions in a channel: + ``` terminal + jq -s '.[] | select( .package == "" ) | select( .schema == "olm.channel" ) | select( .name == "" ) | .entries | .[] | .name' + ``` + + `` + : Name of the package from the catalog you are querying. + + `` + : Name of the channel for a given package. + +* Latest version in a channel and upgrade path: + ``` terminal + jq -s '.[] | select( .schema == "olm.channel" ) | select ( .name == "") | select( .package == "")' + ``` + + `` + : Name of the package from the catalog you are querying. + + `` + : Name of the channel for a given package. ## Bundle queries -Bundles in a package -: -``` terminal -jq -s '.[] | select( .schema == "olm.bundle" ) | select( .package == "") | .name' -``` +* Bundles in a package: + ``` terminal + jq -s '.[] | select( .schema == "olm.bundle" ) | select( .package == "") | .name' + ``` -Bundle dependencies and available APIs -: -``` terminal -jq -s '.[] | select( .schema == "olm.bundle" ) | select ( .name == "") | select( .package == "")' -``` + `` + : Name of the package from the catalog you are querying. + +* Bundle dependencies and available APIs: + ``` terminal + jq -s '.[] | select( .schema == "olm.bundle" ) | select ( .name == "") | select( .package == "")' + ``` + + `` + : Name of the package from the catalog you are querying. + + `` + : Name of the bundle for a given package.