Skip to content

Instantly share code, notes, and snippets.

@dmc5179
Created November 8, 2022 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmc5179/09d8b50af8567d3b68ce660d387a07d1 to your computer and use it in GitHub Desktop.
Save dmc5179/09d8b50af8567d3b68ce660d387a07d1 to your computer and use it in GitHub Desktop.
Script to pull the list of container images that are part of the OpenShift 4 Samples Operator
#!/bin/bash -xe
REGEX="registry.redhat.io|registry.access.redhat.com|quay.io"
OCP_VER="4.11.13"
CONT_NAME="samples_export"
IMG=$(curl -s https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/${OCP_VER}/release.txt | grep cluster-samples-operator | awk '{print $2}')
#mkdir /opt/image_stream_definitions/4.6.16-x86_64
podman pull "${IMG}"
# Make sure its gone
podman rm "${CONT_NAME}" || true
podman create --name="${CONT_NAME}" "${IMG}"
podman export -o fs.tar "${CONT_NAME}"
tar -xf fs.tar opt/openshift/operator/x86_64
for i in $(find . -type f | grep 'imagestreams')
do
jq -r '.spec.tags[].from.name' "${i}" | grep -E "${REGEX}" >> sample_images.txt
# jq -r '.spec.tags[].from.name' "${i}" >> sample_images.txt
done
cat sample_images.txt | sort -u > t
mv t sample_images.txt
# cleanup
sudo rm -rf opt
rm -f fs.tar
podman rm "${CONT_NAME}"
podman rmi "${IMG}"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment