Skip to content

Commit

Permalink
[SRE-398] Bundle legacy provider versions alongside the new one
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeCarrier committed Apr 6, 2023
1 parent 3139d9e commit cdd0970
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ quay_login: &quay_login
run: docker login -u "${DOCKER_USER}" -p "${DOCKER_PASS}" quay.io

install_base: &install_base
run: apk add git bash curl gcc build-base g++ libc-dev openssh-client
run: apk add git bash curl gcc build-base g++ jq libc-dev openssh-client

install_docker: &install_docker
run: apk add docker
Expand Down
36 changes: 35 additions & 1 deletion babylon/build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -exo pipefail
set -euxo pipefail

CONTAINER_NAME=quay.io/babylonhealth/azure-terraform
BINARY_NAME=terraform-provider-bblnazuredevops
Expand All @@ -11,6 +11,10 @@ SEMVER_VERSION="$(git describe --abbrev=0 --tags --match '*-babylon*' | sed -E -
PROVIDER_NAME=bblnazuredevops
PLUGIN_DIR="babylon/terraform.d/plugins/babylonhealth.com/babylonhealth/${PROVIDER_NAME}/${SEMVER_VERSION}/linux_amd64"

REPO_OWNER=babylonhealth
REPO_NAME=terraform-provider-azuredevops
LEGACY_PROVIDER_TAGS=( v0.1.4-babylon.3 v0.1.4-babylon.5 )


run_compile() {
go mod download
Expand All @@ -23,6 +27,34 @@ run_test() {
go test -coverprofile=c.out -v ./...
}

# FIXME: remove this once projects have migrated from the forked provider to the
# supplementary one.
run_fetch_legacy_providers() {
if [[ -z "${GITHUB_TOKEN+x}" ]]; then
echo -e "\tEnvironment variable GITHUB_TOKEN is missing; unable to fetch legacy provider release.\n"
exit 1
fi
local auth_header="Authorization: token $GITHUB_TOKEN"

for tag in "${LEGACY_PROVIDER_TAGS[@]}"; do
local asset_id="$(curl -s \
-H "Accept: application/vnd.github+json" \
-H "$auth_header" \
https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/tags/$tag | jq -r '.assets[0].id')"
if [[ "$asset_id" == "null" ]]; then
echo -e "\tUnable to find asset for tag $tag; did you forget to upload it?\n"
exit 1
fi
# Drop the leading v from the tag name
local dest="babylon/terraform.d/plugins/babylonhealth.com/babylonhealth/azuredevops/${tag:1}/linux_amd64"
mkdir -p $dest
curl -Ls -o "$dest/terraform-provider-azuredevops" \
-H "Accept: application/octet-stream" \
-H "$auth_header" \
https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/assets/$asset_id
done
}

run_docker_compile() {
docker build . -f babylon/Dockerfile.build -t "${CONTAINER_NAME}:build"
docker run --rm -it \
Expand Down Expand Up @@ -68,10 +100,12 @@ main() {
run_test
;;
build)
run_fetch_legacy_providers
run_compile
run_build
;;
docker-build)
run_fetch_legacy_providers
run_docker_compile
run_build
;;
Expand Down

0 comments on commit cdd0970

Please sign in to comment.