mirror of
https://github.com/hashicorp/vault-action.git
synced 2026-05-15 04:50:33 +00:00
Refine e2e-enterprise pipeline and scripts
This commit is contained in:
parent
5305662f7f
commit
136b822494
3 changed files with 56 additions and 10 deletions
35
scripts/.functions
Normal file
35
scripts/.functions
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright IBM Corp. 2019, 2025
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# Adapted from: https://github.com/hashicorp/vault-secrets-operator/blob/main/hack/.functions
|
||||
|
||||
# getGH downloads files from GitHub with optional authentication
|
||||
# Usage: getGH <url> [dest_file] [num_retries]
|
||||
function getGH() {
|
||||
local url="$1"
|
||||
local dest="$2"
|
||||
local num_retries="${3:-${GH_GET_RETRIES}}"
|
||||
|
||||
headers=(
|
||||
'--header' "Accept: application/vnd.github+json"
|
||||
'--header' "X-GitHub-Api-Version: 2022-11-28"
|
||||
)
|
||||
if [ -n "${GITHUB_TOKEN}" ]; then
|
||||
headers+=(
|
||||
'--header' "Authorization: Bearer ${GITHUB_TOKEN}"
|
||||
)
|
||||
fi
|
||||
cmd=curl
|
||||
opts=('-sfSL')
|
||||
echo "Fetching ${url}"
|
||||
if [ -z "${dest}" ]; then
|
||||
opts+=('-O')
|
||||
else
|
||||
opts+=('-o' "${dest}")
|
||||
fi
|
||||
if [ -n "${num_retries}" ]; then
|
||||
opts+=('--retry' "${num_retries}")
|
||||
fi
|
||||
${cmd} "${opts[@]}" "${headers[@]}" "${url}"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue