Skip to content

📖 Change formatting in the "Catalog queries" doc #1461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 81 additions & 46 deletions docs/howto/catalog-queries.md
Original file line number Diff line number Diff line change
@@ -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 | <query>
```
`<query>`
: 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_name>")'
```

Package metadata
:
``` terminal
jq -s '.[] | select( .schema == "olm.package") | select( .name == "<package_name>")'
```
`<package_name>`
: Name of the package from the catalog you are querying.

Catalog blobs in a package
:
``` terminal
jq -s '.[] | select( .package == "<package_name>")'
```
* Catalog blobs in a package:
``` terminal
jq -s '.[] | select( .package == "<package_name>")'
```

`<package_name>`
: 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 == "<package_name>") | .name'
```
* Channels in a package:
``` terminal
jq -s '.[] | select( .schema == "olm.channel" ) | select( .package == "<package_name>") | .name'
```

Versions in a channel
:
``` terminal
jq -s '.[] | select( .package == "<package_name>" ) | select( .schema == "olm.channel" ) | select( .name == "<channel_name>" ) | .entries | .[] | .name'
```
`<package_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 == "<channel>") | select( .package == "<package_name>")'
```
* Versions in a channel:
``` terminal
jq -s '.[] | select( .package == "<package_name>" ) | select( .schema == "olm.channel" ) | select( .name == "<channel_name>" ) | .entries | .[] | .name'
```

`<package_name>`
: Name of the package from the catalog you are querying.

`<channel_name>`
: 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 == "<channel_name>") | select( .package == "<package_name>")'
```

`<package_name>`
: Name of the package from the catalog you are querying.

`<channel_name>`
: Name of the channel for a given package.

## Bundle queries

Bundles in a package
:
``` terminal
jq -s '.[] | select( .schema == "olm.bundle" ) | select( .package == "<package_name>") | .name'
```
* Bundles in a package:
``` terminal
jq -s '.[] | select( .schema == "olm.bundle" ) | select( .package == "<package_name>") | .name'
```

Bundle dependencies and available APIs
:
``` terminal
jq -s '.[] | select( .schema == "olm.bundle" ) | select ( .name == "<bundle_name>") | select( .package == "<package_name>")'
```
`<package_name>`
: Name of the package from the catalog you are querying.

* Bundle dependencies and available APIs:
``` terminal
jq -s '.[] | select( .schema == "olm.bundle" ) | select ( .name == "<bundle_name>") | select( .package == "<package_name>")'
```

`<package_name>`
: Name of the package from the catalog you are querying.

`<bundle_name>`
: Name of the bundle for a given package.