Skip to content

Instantly share code, notes, and snippets.

@nickboldt
Last active March 4, 2022 14:43
Show Gist options
  • Save nickboldt/b62bc2b4c720f93bf406c0be60eb191b to your computer and use it in GitHub Desktop.
Save nickboldt/b62bc2b4c720f93bf406c0be60eb191b to your computer and use it in GitHub Desktop.
querying for IIB versions based on CRW tags
# Get tab-separated values list of metadata containers, IIB bundles, and OCP versions

```
CRW_VERSION=2.12
for csv in operator-metadata operator-bundle; do
  lastcsv=$(curl -sSLk "https://datagrepper.engineering.redhat.com/raw?topic=/topic/VirtualTopic.eng.ci.redhat-container-image.index.built&delta=1728000&rows_per_page=30&contains=codeready-workspaces" | \
jq ".raw_messages[].msg.index | .added_bundle_images[0]" -r | sort -uV | grep "${csv}:${CRW_VERSION}" | tail -1 | \
sed -r -e "s#registry-proxy.engineering.redhat.com/rh-osbs/codeready-workspaces-##");

  curl -sSLk "https://datagrepper.engineering.redhat.com/raw?topic=/topic/VirtualTopic.eng.ci.redhat-container-image.index.built&delta=1728000&rows_per_page=30&contains=codeready-workspaces" | \
jq ".raw_messages[].msg.index | [.added_bundle_images[0], .index_image, .ocp_version] | @tsv" -r | sort -uV | \
grep "${lastcsv}" | sed -r -e "s#registry-proxy.engineering.redhat.com/rh-osbs/codeready-workspaces-#  #";
  echo;
done

```

```
  operator-metadata:2.12-113	registry-proxy.engineering.redhat.com/rh-osbs/iib:116041	v4.6
  operator-metadata:2.12-113	registry-proxy.engineering.redhat.com/rh-osbs/iib:116042	v4.7
  operator-metadata:2.12-113	registry-proxy.engineering.redhat.com/rh-osbs/iib:116043	v4.8
  operator-metadata:2.12-113	registry-proxy.engineering.redhat.com/rh-osbs/iib:116044	v4.9

  operator-bundle:2.12-46	registry-proxy.engineering.redhat.com/rh-osbs/iib:115858	v4.8
  operator-bundle:2.12-46	registry-proxy.engineering.redhat.com/rh-osbs/iib:115859	v4.9

```

## Or this, for a specific OCP version:

```
curl -sSLk "https://datagrepper.engineering.redhat.com/raw?topic=/topic/VirtualTopic.eng.ci.redhat-container-image.index.built&delta=1728000&rows_per_page=30&contains=codeready-workspaces" | jq ".raw_messages[].msg.index | select(.ocp_version==\"v4.8\") | [.added_bundle_images[0], .index_image] | @tsv" -r | sort -uV | tail -2
```

```
registry-proxy.engineering.redhat.com/rh-osbs/codeready-workspaces-operator-metadata:2.10-6	registry-proxy.engineering.redhat.com/rh-osbs/iib:88814
registry-proxy.engineering.redhat.com/rh-osbs/codeready-workspaces-operator-metadata:2.10-7	registry-proxy.engineering.redhat.com/rh-osbs/iib:88834
```

# Introspecting IIB bundles

## oc + sqlitebrowser

  oc image extract --file=/database/index.db --insecure registry-proxy.engineering.redhat.com/rh-osbs/iib:122676
  sqlitebrowser index.db

Then go to Browse Data tab, and sort by package_name to find CRW.

## podman + grpcul + jq

    podman run -p 50051:50051 registry-proxy.engineering.redhat.com/rh-osbs/iib:121356 &

and then any grpcurl command. This will give you all the methods you can use:

    grpcurl -plaintext  localhost:50051 list api.Registry

Then you can call any method for example like this (this will get you list of packages in the bundle:

   grpcurl -plaintext  localhost:50051 api.Registry/ListPackages

or this (will get json of all metadata (array of all CRDs, SCV, ...):

   grpcurl -plaintext -d '{"pkgName":"codeready-workspaces", "channelName":"latest"}' \
     localhost:50051 api.Registry/GetBundleForChannel | jq -cr "." | jq -r .object

Putting it all together:

  # in one console
  podman run -it --rm -p 50051:50051 registry-proxy.engineering.redhat.com/rh-osbs/iib:122676

  # in a second console
  echo;grpcurl -plaintext -d '{"pkgName":"codeready-workspaces", "channelName":"latest"}' \
   localhost:50051 api.Registry/GetBundleForChannel | jq -r .csvJson | \
   jq -r '[.metadata.annotations.createdAt, .metadata.annotations.description, .metadata.annotations.containerImage] | @tsv';
  echo;grpcurl -plaintext -d '{"pkgName":"codeready-workspaces2", "channelName":"tech-preview-latest-all-namespaces"}' \
   localhost:50051 api.Registry/GetBundleForChannel | jq -r .csvJson | \
   jq -r '[.metadata.annotations.createdAt, .metadata.annotations.description, .metadata.annotations.containerImage] | @tsv';

```
2021-09-24T12:34:36+00:00	A Kube-native development solution that delivers portable and collaborative developer workspaces.	registry.redhat.io/codeready-workspaces/crw-2-rhel8-operator@sha256:44112d0f3bb7792aabf96e255ef7822fd7f3f42bc63823bd112b8002317d54d1

2021-10-06T20:40:16+00:00	Technical Preview, OCP 4.8+: Devfile v2 development solution, 1 instance per cluster, for portable, collaborative k8s workspaces.	registry.redhat.io/codeready-workspaces/crw-2-rhel8-operator@sha256:458802564043f3047e477045c9cf4e06ef6b9e41bd8de3a05f482250f326ea28
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment