-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mac/unix and windows test scripts
- Loading branch information
Anna Blendermann
committed
Apr 5, 2023
1 parent
0f65f84
commit 16f2c6a
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<# | ||
This Windows script is to be used to test Terraform RCs locally. It downloads | ||
and installs the given RC. | ||
./setup-provider-windows.ps1 <provider> <version> | ||
Example | ||
./setup-provider-windows.ps1 rancher v3.0.0-rc1 | ||
If you get a cert revocation check error when running the script, curl could | ||
not identify a valid certificate to download the zip. Add --ssl-no-revoke or | ||
--insecure to the curl command and rerun. Alternatives such as white listing | ||
the download link may also work. | ||
#> | ||
|
||
$PROVIDER=$args[0] | ||
$VERSION=$args[1] | ||
$VERSION_TAG=$VERSION.TrimStart("v") | ||
|
||
$DIR="%APPDATA%\terraform.d\plugins\terraform.local\local\${PROVIDER}\${VERSION_TAG}\windows_amd64" | ||
new-item $DIR -itemtype directory | ||
|
||
write-host "Downloading zip..." | ||
$URL="https://github.com/rancher/terraform-provider-${PROVIDER}/releases/download/${VERSION}/terraform-provider-${PROVIDER}_${VERSION_TAG}_windows_amd64.zip" | ||
echo $URL | ||
curl.exe -LO $URL -o terraform-provider-${PROVIDER}_${VERSION_TAG}_windows_amd64.zip | ||
|
||
write-host "Expanding zip..." | ||
Expand-Archive -Force -Path terraform-provider-${PROVIDER}_${VERSION_TAG}_windows_amd64.zip -DestinationPath ${DIR}/terraform-provider-${PROVIDER} | ||
|
||
write-host "Cleaning up..." | ||
Remove-Item -Force -Path terraform-provider-${PROVIDER}_${VERSION_TAG}_windows_amd64.zip | ||
|
||
write-host "Terraform is ready to test!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
# QA has a new process to test Terraform using RCs. We will not publish RCs | ||
# onto the Terraform registry because Hashicorp could potentially block our | ||
# testing by being slow to publish. | ||
|
||
# Instead, we will test using a downloaded binary from the RC. This script | ||
# sets up the correct binary using a defined <provider> <version> to test | ||
# updates locally. | ||
|
||
# ./setup-provider.sh <provider> <version> | ||
|
||
# Example | ||
# ./setup-provider.sh rancher2 v3.0.0-rc1 | ||
|
||
set -e | ||
|
||
# Validate user input | ||
|
||
if [ $# -ne 2 ]; then | ||
echo "Usage: $0 <provider> <version>" | ||
exit 1 | ||
fi | ||
|
||
# Set global vars | ||
|
||
PROVIDER=$1 | ||
VERSION=$2 | ||
VERSION_TAG=$(echo $2 | cut -c 2-) | ||
|
||
# Install gzip | ||
|
||
if ! command -v "gzip" &> /dev/null; then | ||
echo "Missing gzip. Installing..." | ||
brew install gzip | ||
fi | ||
|
||
# Download binary | ||
|
||
OS_PLATFORM=$(uname -sp | tr '[:upper:] ' '[:lower:]_' | sed 's/x86_64/amd64/' | sed 's/i386/amd64/' | sed 's/arm/arm64/') | ||
|
||
DIR=~/.terraform.d/plugins/terraform.local/local/${PROVIDER}/${VERSION_TAG}/${OS_PLATFORM} | ||
mkdir -p $DIR | ||
curl -sfL https://github.com/rancher/terraform-provider-${PROVIDER}/releases/download/${VERSION}/terraform-provider-${PROVIDER}_${VERSION_TAG}_${OS_PLATFORM}.zip | gunzip -c - > ${DIR}/terraform-provider-${PROVIDER} | ||
|
||
# Mod binary | ||
chmod +x ${DIR}/terraform-provider-${PROVIDER} | ||
|
||
echo -e "Terraform provider ${PROVIDER} ${VERSION} is ready to test! | ||
Please update the required_providers block in your Terraform config file | ||
terraform { | ||
required_providers { | ||
rancher2 = { | ||
source = "terraform.local/local/${PROVIDER}" | ||
version = "${VERSION_TAG}" | ||
} | ||
} | ||
}" |