Last active
June 3, 2021 20:39
-
-
Save vancluever/055d43898232e29a210ca0496cb7a79b to your computer and use it in GitHub Desktop.
Get Terraform Registry providers, sort by most downloads (use --community to get community providers only)
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
#!/usr/bin/env bash | |
getproviders() { | |
for (( PAGE=1; ; PAGE++ )); do | |
if [ "$1" == "--community" ]; then | |
DATA="$(curl -fs "https://registry.terraform.io/v2/providers?filter[tier]=community&page[number]=$PAGE")" | |
else | |
DATA="$(curl -fs "https://registry.terraform.io/v2/providers?page[number]=$PAGE")" | |
fi | |
if [ "$(jq '.data' <<< "$DATA")" == "[]" ]; then | |
break | |
fi | |
jq '.data[] | {name: .attributes["full-name"], downloads: .attributes.downloads}' <<< "$DATA" | |
done | |
} | |
column -t <<< "$(jq --raw-output --slurp ' | |
. | sort_by(.downloads) | reverse | | |
to_entries | map({ | |
"#": (.key + 1), | |
"name": .value.name, | |
"downloads": .value.downloads | |
}) | | |
((.[0] | keys_unsorted), (.[] | . | map(.))) | @tsv' <<< "$(getproviders "$@")")" |
Updated (again) to default to all providers with --community
option now to do community only.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to provide rank with sorted output.
Note that the rank works off of index number only, hence ties are not listed as the same number.