2022-01-17 01:57:02 +01:00
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p gh
|
|
|
|
# shellcheck shell=bash
|
2020-09-24 16:02:12 +02:00
|
|
|
# Bash 3 compatible for Darwin
|
2019-10-31 17:05:06 +01:00
|
|
|
|
2022-01-17 01:57:02 +01:00
|
|
|
if [ -z "${GITHUB_TOKEN}" ]; then
|
|
|
|
echo >&2 "usage: GITHUB_TOKEN=… ./update.sh"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-10-03 20:20:32 +02:00
|
|
|
|
2020-09-24 16:02:12 +02:00
|
|
|
# Version of Pulumi from
|
|
|
|
# https://www.pulumi.com/docs/get-started/install/versions/
|
2022-03-02 22:45:12 +01:00
|
|
|
VERSION="3.25.1"
|
2019-10-31 17:05:06 +01:00
|
|
|
|
2022-01-06 17:40:59 +01:00
|
|
|
# An array of plugin names. The respective repository inside Pulumi's
|
|
|
|
# Github organization is called pulumi-$name by convention.
|
2021-10-03 20:20:32 +02:00
|
|
|
|
2022-01-17 01:57:02 +01:00
|
|
|
declare -a pulumi_repos
|
2021-10-03 20:20:32 +02:00
|
|
|
pulumi_repos=(
|
2022-03-02 22:45:12 +01:00
|
|
|
"aiven"
|
|
|
|
"akamai"
|
|
|
|
"alicloud"
|
|
|
|
"artifactory"
|
2022-01-17 01:57:02 +01:00
|
|
|
"auth0"
|
|
|
|
"aws"
|
|
|
|
"azure"
|
2022-03-02 22:45:12 +01:00
|
|
|
"azuread"
|
|
|
|
"azuredevops"
|
2022-01-17 01:57:02 +01:00
|
|
|
"cloudflare"
|
|
|
|
"consul"
|
|
|
|
"datadog"
|
|
|
|
"digitalocean"
|
|
|
|
"docker"
|
|
|
|
"equinix-metal"
|
2022-03-02 22:45:12 +01:00
|
|
|
"fastly"
|
2022-01-17 01:57:02 +01:00
|
|
|
"gcp"
|
|
|
|
"github"
|
|
|
|
"gitlab"
|
|
|
|
"hcloud"
|
|
|
|
"kubernetes"
|
|
|
|
"linode"
|
|
|
|
"mailgun"
|
|
|
|
"mysql"
|
|
|
|
"openstack"
|
|
|
|
"postgresql"
|
|
|
|
"random"
|
2022-03-02 22:45:12 +01:00
|
|
|
"snowflake"
|
|
|
|
"spotinst"
|
|
|
|
"sumologic"
|
|
|
|
"tailscale"
|
|
|
|
"tls"
|
2022-01-17 01:57:02 +01:00
|
|
|
"vault"
|
2022-03-02 22:45:12 +01:00
|
|
|
"venafi"
|
2022-01-17 01:57:02 +01:00
|
|
|
"vsphere"
|
2022-03-02 22:45:12 +01:00
|
|
|
"wavefront"
|
|
|
|
"yandex"
|
2021-01-18 15:51:36 +01:00
|
|
|
)
|
2019-10-31 17:05:06 +01:00
|
|
|
|
2021-10-03 20:20:32 +02:00
|
|
|
# Contains latest release ${VERSION} from
|
|
|
|
# https://github.com/pulumi/pulumi-${NAME}/releases
|
|
|
|
|
2022-01-17 01:57:02 +01:00
|
|
|
# Dynamically builds the plugin array, using the GitHub API for getting the
|
2022-01-06 17:40:59 +01:00
|
|
|
# latest version.
|
2022-01-17 01:57:02 +01:00
|
|
|
plugin_num=1
|
2021-10-03 20:20:32 +02:00
|
|
|
plugins=()
|
2022-01-06 17:40:59 +01:00
|
|
|
for key in "${pulumi_repos[@]}"; do
|
2022-01-17 01:57:02 +01:00
|
|
|
plugin="${key}=$(gh api "repos/pulumi/pulumi-${key}/releases/latest" --jq '.tag_name | sub("^v"; "")')"
|
|
|
|
printf "%20s: %s of %s\r" "${plugin}" "${plugin_num}" "${#pulumi_repos[@]}"
|
|
|
|
plugins+=("${plugin}")
|
|
|
|
sleep 1
|
|
|
|
((++plugin_num))
|
2021-10-03 20:20:32 +02:00
|
|
|
done
|
2022-01-17 01:57:02 +01:00
|
|
|
printf "\n"
|
2021-10-03 20:20:32 +02:00
|
|
|
|
2019-10-31 17:05:06 +01:00
|
|
|
function genMainSrc() {
|
2022-01-17 01:57:02 +01:00
|
|
|
local url="https://get.pulumi.com/releases/sdk/pulumi-v${VERSION}-${1}-${2}.tar.gz"
|
|
|
|
local sha256
|
|
|
|
sha256=$(nix-prefetch-url "$url")
|
|
|
|
echo " {"
|
|
|
|
echo " url = \"${url}\";"
|
|
|
|
echo " sha256 = \"$sha256\";"
|
|
|
|
echo " }"
|
|
|
|
}
|
|
|
|
|
|
|
|
function genSrc() {
|
|
|
|
local url="${1}"
|
|
|
|
local plug="${2}"
|
|
|
|
local tmpdir="${3}"
|
|
|
|
|
|
|
|
local sha256
|
|
|
|
sha256=$(nix-prefetch-url "$url")
|
|
|
|
|
|
|
|
{
|
|
|
|
if [ -n "$sha256" ]; then # file exists
|
|
|
|
echo " {"
|
|
|
|
echo " url = \"${url}\";"
|
|
|
|
echo " sha256 = \"$sha256\";"
|
|
|
|
echo " }"
|
|
|
|
else
|
|
|
|
echo " # pulumi-resource-${plug} skipped (does not exist on remote)"
|
|
|
|
fi
|
|
|
|
} > "${tmpdir}/${plug}.nix"
|
2019-10-31 17:05:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function genSrcs() {
|
2022-01-17 01:57:02 +01:00
|
|
|
local tmpdir
|
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
|
|
|
|
local i=0
|
|
|
|
|
|
|
|
for plugVers in "${plugins[@]}"; do
|
|
|
|
local plug=${plugVers%=*}
|
|
|
|
local version=${plugVers#*=}
|
|
|
|
# url as defined here
|
|
|
|
# https://github.com/pulumi/pulumi/blob/06d4dde8898b2a0de2c3c7ff8e45f97495b89d82/pkg/workspace/plugins.go#L197
|
|
|
|
local url="https://api.pulumi.com/releases/plugins/pulumi-resource-${plug}-v${version}-${1}-${2}.tar.gz"
|
|
|
|
genSrc "${url}" "${plug}" "${tmpdir}" &
|
|
|
|
((++i))
|
|
|
|
done
|
|
|
|
|
|
|
|
wait
|
|
|
|
|
|
|
|
find "${tmpdir}" -name '*.nix' -print0 | sort -z | xargs -r0 cat
|
|
|
|
rm -r "${tmpdir}"
|
2019-10-31 17:05:06 +01:00
|
|
|
}
|
|
|
|
|
2021-02-27 13:27:31 +01:00
|
|
|
{
|
2022-01-17 01:57:02 +01:00
|
|
|
cat << EOF
|
2019-10-31 17:05:06 +01:00
|
|
|
# DO NOT EDIT! This file is generated automatically by update.sh
|
|
|
|
{ }:
|
|
|
|
{
|
|
|
|
version = "${VERSION}";
|
|
|
|
pulumiPkgs = {
|
|
|
|
EOF
|
2021-09-09 22:19:11 +02:00
|
|
|
|
|
|
|
echo " x86_64-linux = ["
|
|
|
|
genMainSrc "linux" "x64"
|
|
|
|
genSrcs "linux" "amd64"
|
2021-02-27 13:27:31 +01:00
|
|
|
echo " ];"
|
2021-09-09 22:19:11 +02:00
|
|
|
|
2021-02-27 13:27:31 +01:00
|
|
|
echo " x86_64-darwin = ["
|
2021-09-09 22:19:11 +02:00
|
|
|
genMainSrc "darwin" "x64"
|
|
|
|
genSrcs "darwin" "amd64"
|
|
|
|
echo " ];"
|
2019-10-31 17:05:06 +01:00
|
|
|
|
2021-09-09 22:19:11 +02:00
|
|
|
echo " aarch64-linux = ["
|
|
|
|
genMainSrc "linux" "arm64"
|
|
|
|
genSrcs "linux" "arm64"
|
2021-02-27 13:27:31 +01:00
|
|
|
echo " ];"
|
2021-09-09 22:19:11 +02:00
|
|
|
|
|
|
|
echo " aarch64-darwin = ["
|
|
|
|
genMainSrc "darwin" "arm64"
|
|
|
|
genSrcs "darwin" "arm64"
|
|
|
|
echo " ];"
|
|
|
|
|
2021-02-27 13:27:31 +01:00
|
|
|
echo " };"
|
|
|
|
echo "}"
|
2021-09-09 22:19:11 +02:00
|
|
|
|
2021-02-27 13:27:31 +01:00
|
|
|
} > data.nix
|