Last active
January 24, 2022 17:43
-
-
Save robbmanes/5e369dd078badbc053cf1085e950f360 to your computer and use it in GitHub Desktop.
Test functionality of Red Hat Container Registries manually
This file contains 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 | |
# rh-container-registry.sh | |
# Test functionality of Red Hat Container Registries using pure HTTP/S. | |
# Useful for determining issues when/if behind proxies, load balancers, | |
# or other in-the-middle network devices. | |
# For more information on using Red Hat Container Registries, please see | |
# the following: | |
# https://access.redhat.com/RegistryAuthentication | |
# Please fill out the following section prior to running the script. | |
# Input your username or service account and password/token. | |
USERNAME="username" | |
PASSWORD="password" | |
# Only change the endpoint if you are testing other registry endpoints. | |
RH_ENDPOINT="https://registry.redhat.io:443" | |
# Image to query for testing purposes | |
IMAGE_QUERY="ubi8/ubi-minimal" | |
######################################## | |
function log() { | |
echo "[$(date +"%Y-%m-%d %T")]: ${1}" | |
} | |
function endf() { | |
echo "==============================" | |
} | |
function dig_registry() { | |
log "Performing DNS lookup of registry..." | |
dig $RH_ENDPOINT | |
endf | |
} | |
function ping_registry() { | |
log "Performing \"ping\" to registry..." | |
curl -k -v \ | |
-H "Docker-Distribution-Api-Version: registry/2.0" \ | |
-G "${RH_ENDPOINT}/v2/_ping" | |
endf | |
} | |
function basic_http_login() { | |
log "Attempting Basic Authorization Login Method..." | |
TOKEN=$(echo -n ${USERNAME}:${PASSWORD} | base64 | tr -d '\n') | |
curl -k -v \ | |
-H "Authorization: Basic ${TOKEN}" \ | |
-H "Accept-Encoding: gzip" \ | |
-H "Docker-Distribution-Api-Version: registry/2.0" \ | |
-G "${RH_ENDPOINT}/auth/realms/rhcc/protocol/redhat-docker-v2/auth" \ | |
--data-urlencode "account=${USERNAME}" \ | |
--data-urlencode "service=docker-registry" | |
endf | |
} | |
function main() { | |
dig_registry | |
ping_registry | |
basic_http_login | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment