Skip to content

Commit

Permalink
chore: Update scripts to be "self" documenting.
Browse files Browse the repository at this point in the history
  • Loading branch information
spbsoluble committed Feb 20, 2024
1 parent a65a134 commit 337396e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
11 changes: 10 additions & 1 deletion scripts/test_curl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
set -e -o pipefail
DEBUG=0

function help() {
echo "Usage: ./test_curl.sh"
echo "This script prompts for the secret server URL, secret ID, username, and password if they're not set, authenticates and gets a token, uses the token to fetch the secret with the given ID, and then unsets the variables."
echo "You can set the following environment variables to avoid being prompted:"
echo " SECRET_SERVER_URL: The URL of your secret server"
echo " SECRET_SERVER_SECRET_ID: The ID of your secret"
echo " SECRET_SERVER_USERNAME: Your secret server username"
echo " SECRET_SERVER_PASSWORD: Your secret server password"
}

# function that checks if DEBUG is true and prints the output of the argument
function debug() {
Expand Down Expand Up @@ -61,7 +70,7 @@ fi
# Check that no values are empty
if [ -z "$SECRET_SERVER_URL" ] || [ -z "$SECRET_SERVER_SECRET_ID" ] || [ -z "$SECRET_SERVER_USERNAME" ] || [ -z "$SECRET_SERVER_PASSWORD" ]; then
echo "Please provide all the required values. Exiting..."
exit 1
help
fi

# Check if URL is prefixed with http or https
Expand Down
12 changes: 11 additions & 1 deletion scripts/test_pwsh.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
$DEBUG=0

function help() {
Write-Host "Usage: .\test_pwsh.ps1"
Write-Host "This script prompts for the secret server URL, secret ID, username, and password if they're not set, authenticates and gets a token, uses the token to fetch the secret with the given ID, and then unsets the variables."
Write-Host "You can set the following environment variables to avoid being prompted:"
Write-Host " SECRET_SERVER_URL: The URL of your secret server"
Write-Host " SECRET_SERVER_SECRET_ID: The ID of your secret"
Write-Host " SECRET_SERVER_USERNAME: Your secret server username"
Write-Host " SECRET_SERVER_PASSWORD: Your secret server password"
}

function debug($message) {
if ($DEBUG) {
Write-Host $message
Expand Down Expand Up @@ -32,7 +42,7 @@ if (![string]::IsNullOrEmpty($env:SECRET_SERVER_PASSWORD)) {

if ([string]::IsNullOrEmpty($SECRET_SERVER_URL) -or [string]::IsNullOrEmpty($SECRET_SERVER_SECRET_ID) -or [string]::IsNullOrEmpty($SECRET_SERVER_USERNAME) -or [string]::IsNullOrEmpty($SECRET_SERVER_PASSWORD)) {
Write-Host "Please provide all the required values. Exiting..."
exit
help
}

if (!($SECRET_SERVER_URL -match '^https?://')) {
Expand Down

0 comments on commit 337396e

Please # to comment.