Skip to content

Commit 31c3ead

Browse files
committed
add transforming source to remove, inject, and transform metrics and dimensions
1 parent bf89e7f commit 31c3ead

File tree

7 files changed

+1320
-3
lines changed

7 files changed

+1320
-3
lines changed

jdk-wrapper.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ safe_command() {
4040
fi
4141
}
4242

43+
checksum() {
44+
l_file="$1"
45+
checksum_exec=""
46+
if command -v md5 > /dev/null; then
47+
checksum_exec="md5"
48+
elif command -v sha1sum > /dev/null; then
49+
checksum_exec="sha1sum"
50+
elif command -v shasum > /dev/null; then
51+
checksum_exec="shasum"
52+
fi
53+
if [ -z "${checksum_exec}" ]; then
54+
log_err "ERROR: No supported checksum command found!"
55+
exit 1
56+
fi
57+
cat "${l_file}" | ${checksum_exec}
58+
}
59+
60+
rand() {
61+
awk 'BEGIN {srand();printf "%d\n", (rand() * 10^8);}'
62+
}
63+
4364
download() {
4465
file="$1"
4566
if [ ! -f "${JDKW_PATH}/${file}" ]; then
@@ -93,7 +114,10 @@ fi
93114

94115
# Resolve latest version
95116
if [ "${JDKW_RELEASE}" = "latest" ]; then
96-
JDKW_RELEASE=$(curl ${CURL_OPTIONS} -f -k -L -H 'Accept: application/json' "${JDKW_BASE_URI}/releases/latest" | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
117+
latest_version_json="${TMPDIR:-/tmp}/jdkw-latest-version-$$.$(rand)"
118+
safe_command "curl ${CURL_OPTIONS} -f -k -L -o \"${latest_version_json}\" -H 'Accept: application/json' \"${JDKW_BASE_URI}/releases/latest\""
119+
JDKW_RELEASE=$(cat "${latest_version_json}" | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
120+
rm -f "${latest_version_json}"
97121
log_out "Resolved latest version to ${JDKW_RELEASE}"
98122
fi
99123

@@ -114,7 +138,7 @@ download "${JDKW_WRAPPER}"
114138
# Check whether this wrapper is the one specified for this version
115139
jdkw_download="${JDKW_PATH}/${JDKW_WRAPPER}"
116140
jdkw_current="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)/$(basename "$0")"
117-
if [ "$(cat "${jdkw_download}" | sha1sum )" != "$(cat "${jdkw_current}" | sha1sum)" ]; then
141+
if [ "$(checksum "${jdkw_download}")" != "$(checksum "${jdkw_current}")" ]; then
118142
printf "\e[0;31m[WARNING]\e[0m Your jdk-wrapper.sh file does not match the one in your JDKW_RELEASE.\n"
119143
printf "\e[0;32mUpdate your jdk-wrapper.sh to match by running:\e[0m\n"
120144
printf "cp \"%s\" \"%s\"\n" "${jdkw_download}" "${jdkw_current}"

0 commit comments

Comments
 (0)