Last active
November 7, 2018 20:33
-
-
Save liveaverage/78a6373bba0708de0be938ae5a424504 to your computer and use it in GitHub Desktop.
Bash script enumerate all OCP docker images from Red Hat Container Registry while filtering out CFME,Openstack,preview,beta,etc. This filters by desired OCP version. Useful for disconnected OCP installations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: JR Morgan <[email protected]> | |
# Enumerate all images while filtering out CFME,Openstack,preview,beta,etc. and | |
# Filter images by platform version | |
version="3.9" | |
## Set to "" for standard registry. Trailing slash must be present when specifying a prefix | |
repoprefix="your.internalregistry.com:18443/" | |
images=$(curl -s https://registry.access.redhat.com/v1/search?q=* | python -mjson.tool | grep '"name":' | grep -E -v '(preview|beta|cloudforms|openstack|rhmap)' | grep -E '(dotnet|jboss|openshift3|httpd|ruby|nodejs|python|perl|php|mysql|mariadb|mongodb|postgres|redis|sso|jdk)' | awk '{ gsub("\"",""); gsub(",",""); print($2)}') | |
echo "#!/bin/bash" > xpaas-images.sh | |
for i in $images; do | |
tags=$(curl -s https://registry.access.redhat.com/v1/repositories/${i}/tags | python -mjson.tool | grep -v -E '(-|latest)' | grep ':' | awk '{ gsub("\"",""); gsub(":",""); print($1)}') | |
for t in $tags; do | |
if [[ $i = *"openshift3/ose"* ]] || [[ $i = *"openshift3/apb"* ]] || [[ $i = *"openshift3/jenkins"* ]] || [[ $i = *"openshift3/logging"* ]] || [[ $i = *"openshift3/metrics"* ]] || \ | |
[[ $i = *"openshift3/container-engine"* ]] || [[ $i = *"openshift3/cri-o"* ]] || [[ $i = *"openshift3/image-inspector"* ]] || [[ $i = *"openshift3/local-storage"* ]] || [[ $i = *"-apb"* ]] || \ | |
[[ $i = *"openshift3/node"* ]] || [[ $i = *"openshift3/openvswitch"* ]] || [[ $i = *"openshift3/oauth-proxy"* ]] || [[ $i = *"openshift3/prometheus"* ]] || [[ $i = *"openshift3/registry"* ]] || \ | |
[[ $i = *"openshift3/snapshot"* ]] || [[ $i = *"openshift3/mediawiki"* ]]; then | |
if [[ $t = *"${version}"* ]]; then | |
echo "docker pull ${repoprefix}${i}:${t}" >> xpaas-images.sh | |
echo "docker pull ${repoprefix}${i}:${t}" | |
fi | |
else | |
echo "docker pull ${repoprefix}${i}:${t}" >> xpaas-images.sh | |
echo "docker pull ${repoprefix}${i}:${t}" | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment