2020-04-24 23:36:52 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-09-25 04:45:31 +00:00
|
|
|
# Bash 3 compatible for Darwin
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
# For getting the latest version of plugins automatically
|
|
|
|
API_URL="https://api.github.com/repos/pulumi"
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
# Version of Pulumi from
|
|
|
|
# https://www.pulumi.com/docs/get-started/install/versions/
|
2022-01-13 20:06:32 +00:00
|
|
|
VERSION="3.21.0"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
# An array of plugin names. The respective repository inside Pulumi's
|
|
|
|
# Github organization is called pulumi-$name by convention.
|
2021-10-04 12:37:57 +00:00
|
|
|
|
|
|
|
pulumi_repos=(
|
2022-01-13 20:06:32 +00:00
|
|
|
"auth0"
|
|
|
|
"aws"
|
|
|
|
"azure"
|
|
|
|
"cloudflare"
|
|
|
|
"consul"
|
|
|
|
"datadog"
|
|
|
|
"digitalocean"
|
|
|
|
"docker"
|
|
|
|
"equinix-metal"
|
|
|
|
"gcp"
|
|
|
|
"github"
|
|
|
|
"gitlab"
|
|
|
|
"hcloud"
|
|
|
|
"kubernetes"
|
|
|
|
"linode"
|
|
|
|
"mailgun"
|
|
|
|
"mysql"
|
|
|
|
"openstack"
|
|
|
|
"packet"
|
|
|
|
"postgresql"
|
|
|
|
"random"
|
|
|
|
"vault"
|
|
|
|
"vsphere"
|
2021-02-05 17:12:51 +00:00
|
|
|
)
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
# Contains latest release ${VERSION} from
|
|
|
|
# https://github.com/pulumi/pulumi-${NAME}/releases
|
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
# Dynamically builds the plugin array, using the API for getting the
|
|
|
|
# latest version.
|
2021-10-04 12:37:57 +00:00
|
|
|
plugins=()
|
2022-01-13 20:06:32 +00:00
|
|
|
for key in "${pulumi_repos[@]}"; do
|
|
|
|
repo="pulumi-${key}"
|
|
|
|
plugins+=("${key}=$(curl -s ${API_URL}/${repo}/releases/latest | jq -M -r .tag_name | sed 's/v//g')")
|
2021-10-04 12:37:57 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
function genMainSrc() {
|
2021-09-18 10:52:07 +00:00
|
|
|
local url="https://get.pulumi.com/releases/sdk/pulumi-v${VERSION}-${1}-${2}.tar.gz"
|
2020-04-24 23:36:52 +00:00
|
|
|
local sha256
|
|
|
|
sha256=$(nix-prefetch-url "$url")
|
|
|
|
echo " {"
|
|
|
|
echo " url = \"${url}\";"
|
|
|
|
echo " sha256 = \"$sha256\";"
|
|
|
|
echo " }"
|
|
|
|
}
|
|
|
|
|
|
|
|
function genSrcs() {
|
2020-07-18 16:06:22 +00:00
|
|
|
for plugVers in "${plugins[@]}"; do
|
|
|
|
local plug=${plugVers%=*}
|
|
|
|
local version=${plugVers#*=}
|
2020-04-24 23:36:52 +00:00
|
|
|
# url as defined here
|
|
|
|
# https://github.com/pulumi/pulumi/blob/06d4dde8898b2a0de2c3c7ff8e45f97495b89d82/pkg/workspace/plugins.go#L197
|
2021-09-18 10:52:07 +00:00
|
|
|
local url="https://api.pulumi.com/releases/plugins/pulumi-resource-${plug}-v${version}-${1}-${2}.tar.gz"
|
2020-04-24 23:36:52 +00:00
|
|
|
local sha256
|
|
|
|
sha256=$(nix-prefetch-url "$url")
|
2021-09-18 10:52:07 +00:00
|
|
|
if [ "$sha256" ]; then # file exists
|
|
|
|
echo " {"
|
|
|
|
echo " url = \"${url}\";"
|
|
|
|
echo " sha256 = \"$sha256\";"
|
|
|
|
echo " }"
|
|
|
|
else
|
|
|
|
echo " # pulumi-resource-${plug} skipped (does not exist on remote)"
|
|
|
|
fi
|
2020-04-24 23:36:52 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
{
|
|
|
|
cat <<EOF
|
2020-04-24 23:36:52 +00:00
|
|
|
# DO NOT EDIT! This file is generated automatically by update.sh
|
|
|
|
{ }:
|
|
|
|
{
|
|
|
|
version = "${VERSION}";
|
|
|
|
pulumiPkgs = {
|
|
|
|
EOF
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
echo " x86_64-linux = ["
|
|
|
|
genMainSrc "linux" "x64"
|
|
|
|
genSrcs "linux" "amd64"
|
2021-03-09 03:18:52 +00:00
|
|
|
echo " ];"
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
echo " x86_64-darwin = ["
|
2021-09-18 10:52:07 +00:00
|
|
|
genMainSrc "darwin" "x64"
|
|
|
|
genSrcs "darwin" "amd64"
|
|
|
|
echo " ];"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
echo " aarch64-linux = ["
|
|
|
|
genMainSrc "linux" "arm64"
|
|
|
|
genSrcs "linux" "arm64"
|
2021-03-09 03:18:52 +00:00
|
|
|
echo " ];"
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
echo " aarch64-darwin = ["
|
|
|
|
genMainSrc "darwin" "arm64"
|
|
|
|
genSrcs "darwin" "arm64"
|
|
|
|
echo " ];"
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
echo " };"
|
|
|
|
echo "}"
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
} > data.nix
|