- Install
gcloud - Configure account auth via
gcloud auth login - Install
jq
./dump.sh | tee gcr-containers-images.txtgcloudgcloud auth loginjq./dump.sh | tee gcr-containers-images.txt| #!/bin/bash | |
| set -e | |
| main() { | |
| local repository="google-containers" | |
| dump_image_tags $repository | |
| } | |
| dump_image_tags() { | |
| local repository=$1 | |
| images=$(get_image_list $repository) | |
| for image in $images; do | |
| if [ ! -z "$image" ]; then | |
| tags=$(get_image_tags $image) | |
| for tag in $tags; do | |
| echo "$image:$tag" | |
| done | |
| fi | |
| done | |
| } | |
| get_image_list() { | |
| local repository=$1 | |
| gcloud container images list --repository "gcr.io/$repository" --quiet --format="csv[no-heading](Name)" | |
| } | |
| get_image_tags() { | |
| local image=$1 | |
| gcloud container images list-tags "$image" --quiet --filter="tags:*" --format="json(tags)" | jq -r ".[]|flatten|.[]|." | |
| } | |
| main "$@" |