Skip to content

Commit

Permalink
chore: Set User-Agent HTTP Header in cURL requests
Browse files Browse the repository at this point in the history
This will make it easier for the content gateway server to identify
this plugin and categorize requests coming from it accordingly.
  • Loading branch information
rm3l committed Apr 27, 2022
1 parent ee7a5d1 commit 33c2a1c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- main
pull_request:

env:
# Change version number prior to tagging new releases of this plugin
ASDF_ODO_USER_AGENT: "asdf-odo/1.2.0 (CI)"

jobs:
plugin_test:
name: test
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ defaults:
run:
shell: wsl-bash {0}

env:
# Change version number prior to tagging new releases of this plugin
ASDF_ODO_USER_AGENT: "asdf-odo/1.2.0 (CI)"

jobs:
plugin_test:
# Disable job forever, since neither ASDF nor Vampire/setup-wsl support WSL at this time:
Expand Down
11 changes: 6 additions & 5 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ uname_arch() {
echo "$arch"
}

curl_opts=(-fsSL)
# Change version number prior to tagging new releases of this plugin
curl_opts=(-fsSL -A "${ASDF_ODO_USER_AGENT:-"asdf-$TOOL_NAME/1.2.0"}")

# NOTE: You might want to remove this if odo is not hosted on GitHub releases.
if [ -n "${GITHUB_API_TOKEN:-}" ]; then
Expand Down Expand Up @@ -89,7 +90,7 @@ download_ref() {
filename="$file_dl_dir/src.zip"
[ -f "$filename" ] || (
echo "* Downloading source code archive for $TOOL_NAME (ref: $gh_ref)..."
log_verbose "Download URL" "$url"
log_verbose "Download URL" "$url" ", using curl options: '${curl_opts[@]}'"
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
)

Expand Down Expand Up @@ -132,13 +133,13 @@ download_release() {
url="https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/$TOOL_NAME/v${versionForDl}/$TOOL_NAME-${os_arch}${binaryExtension}"

echo "* Downloading $TOOL_NAME release $version, for $os_arch..."
log_verbose "Download URL: " "$url"
log_verbose "Download URL: " "$url" ", using curl options: '${curl_opts[@]}'"
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
log_verbose "Downloaded file $filename: " "$url"
log_verbose "Downloaded file $filename"

echo "* Verifying filename integrity..."
shaurl="${url}.sha256"
log_verbose "Download URL: " "$shaurl"
log_verbose "Download URL: " "$shaurl" ", using curl options: '${curl_opts[@]}'"
shafilename="$filename.sha256"
curl "${curl_opts[@]}" -o "$shafilename" -C - "$shaurl" || fail "Could not download $shaurl"
(echo "$(<$shafilename) $filename" | shasum -a 256 --check) || fail "Could not check integrity of downloaded file"
Expand Down

0 comments on commit 33c2a1c

Please sign in to comment.