-
Notifications
You must be signed in to change notification settings - Fork 108
/
get_providers.sh
executable file
·35 lines (32 loc) · 1.33 KB
/
get_providers.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# AUTHOR: Phil Porada - philporada@gmail.com
# TICKET: https://github.com/hashivim/vim-terraform/issues/40
# WHAT: As of Terraform 0.10.0, Hashicorp split out each provider into its own
# separate terraform-provider-* project. As a result, we have to hunt
# for all of the resources that each provider provides. This is a PITA
# but I guess good for Terraform. ¯\_(ツ)_/¯
command -v jq >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "You need to install jq. Exiting..."
exit 1
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=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
if [ ! -d $i ]; then
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}
find -type f -not -name "*provider*.go" -delete
cd ..
else
cd ${i}
git pull --hard --depth 1 https://github.com/terraform-providers/${i}
cd ..
fi
done
}
get_providers