Skip to content

Commit

Permalink
Overhauled this script
Browse files Browse the repository at this point in the history
  • Loading branch information
pgporada committed Dec 25, 2018
1 parent cb840e9 commit 259481e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions get_providers.sh
Expand Up @@ -15,22 +15,19 @@ fi
function get_providers() {
mkdir -p terraform-providers
# Make a ramdisk because there is a ton of stuff to download
sudo mount -t tmpfs -o size=3096m tmpfs $(pwd)/terraform-providers
sudo mount -t tmpfs -o size=512m tmpfs $(pwd)/terraform-providers
cd terraform-providers
for i in $(curl -sL https://api.github.com/users/terraform-providers/repos?per_page=300 | jq -r .[].name); do
PROVIDER="$(echo ${i} | awk -F'-' '{print $3}')"
if [ ! -d $i ]; then
git clone --depth 1 https://github.com/terraform-providers/$i
git clone --depth 1 https://github.com/terraform-providers/${i}
# Only get the folder/files we need. There's probably a better way checkout only the files we need, but I don't know it.
cd ${i}
git filter-branch --prune-empty --subdirectory-filter ${PROVIDER} -- --all
git filter-branch -f --prune-empty --index-filter 'git rm --cached --ignore-unmatch $(git ls-files | grep -v "provider*.go")'
rm -rf vendor
find -type f -not -name "*provider*.go" -delete
cd ..
else
pushd $i
git pull --hard --depth 1 https://github.com/terraform-providers/$i
popd
cd ${i}
git pull --hard --depth 1 https://github.com/terraform-providers/${i}
cd ..
fi
done
}
Expand Down

0 comments on commit 259481e

Please sign in to comment.