more shellcheck

Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
This commit is contained in:
Jess Frazelle
2018-09-24 19:17:06 -04:00
parent 43fab0cce2
commit 5eccef3c66
7 changed files with 26 additions and 17 deletions

View File

@@ -16,14 +16,17 @@ AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}"
get_latest() {
local repo=$1
local resp=$(curl -sSL -H "${AUTH_HEADER}" -H "${API_HEADER}" "${URI}/repos/${repo}/releases")
local tag=$(echo $resp | jq -e --raw-output .[0].tag_name)
local name=$(echo $resp | jq -e --raw-output .[0].name)
local resp
resp=$(curl -sSL -H "${AUTH_HEADER}" -H "${API_HEADER}" "${URI}/repos/${repo}/releases")
local tag
tag=$(echo "$resp" | jq -e --raw-output .[0].tag_name)
local name
name=$(echo "$resp" | jq -e --raw-output .[0].name)
if [[ "$tag" == "null" ]]; then
# get the latest tag
local resp=$(curl -sSL -H "${AUTH_HEADER}" -H "${API_HEADER}" "${URI}/repos/${repo}/tags")
local tag=$(echo $resp | jq -e --raw-output .[0].name)
resp=$(curl -sSL -H "${AUTH_HEADER}" -H "${API_HEADER}" "${URI}/repos/${repo}/tags")
tag=$(echo "$resp" | jq -e --raw-output .[0].name)
tag=${tag#release-}
fi
@@ -52,7 +55,8 @@ get_latest() {
fi
# Change to upper case for grep
local udir=$(echo $dir | awk '{print toupper($0)}')
local udir
udir=$(echo $dir | awk '{print toupper($0)}')
# Replace dashes (-) with underscores (_)
udir=${udir//-/_}
udir=${udir%/*}
@@ -60,9 +64,9 @@ get_latest() {
local current
if [[ ! -d "$dir" ]]; then
# If the directory does not exist, then grep all for it
current=$(grep -m 1 "${udir}_VERSION" **/Dockerfile | head -n 1 | awk '{print $(NF)}')
current=$(grep -m 1 "${udir}_VERSION" -- **/Dockerfile | head -n 1 | awk '{print $(NF)}')
else
current=$(cat "${dir}/Dockerfile" | grep -m 1 "${udir}_VERSION" | awk '{print $(NF)}')
current=$(grep -m 1 "${udir}_VERSION" "${dir}/Dockerfile" | awk '{print $(NF)}')
fi
@@ -85,14 +89,14 @@ compare() {
local name="$1" dir="$2" tag="$3" current="$4" releases="$5"
ignore_dirs=( "bazel" "bcc" "mc" "nzbget" "osquery" "powershell" "rstudio" )
if [[ "$tag" =~ "$current" ]] || [[ "$name" =~ "$current" ]] || [[ "$current" =~ "$tag" ]] || [[ "$current" == "master" ]]; then
echo -e "\e[36m${dir}:\e[39m current ${current} | ${tag} | ${name}"
if [[ "$tag" =~ $current ]] || [[ "$name" =~ $current ]] || [[ "$current" =~ $tag ]] || [[ "$current" == "master" ]]; then
echo -e "\\e[36m${dir}:\\e[39m current ${current} | ${tag} | ${name}"
else
# add to the bad versions
if [[ ! " ${ignore_dirs[@]} " =~ " ${dir} " ]]; then
if [[ ! " ${ignore_dirs[*]} " =~ ${dir} ]]; then
bad_versions+=( "${dir}" )
fi
echo -e "\e[31m${dir}:\e[39m current ${current} | ${tag} | ${name} | ${releases}"
echo -e "\\e[31m${dir}:\\e[39m current ${current} | ${tag} | ${name} | ${releases}"
fi
}
@@ -152,16 +156,18 @@ unifi
bad_versions=()
main() {
# shellcheck disable=SC2068
for p in ${projects[@]}; do
get_latest "$p"
done
# shellcheck disable=SC2068
for p in ${other_projects[@]}; do
get_latest_"$p"
done
if [[ ${#bad_versions[@]} -ne 0 ]]; then
echo
echo "These Dockerfiles are not up to date: ${bad_versions[@]}" >&2
echo "These Dockerfiles are not up to date: ${bad_versions[*]}" >&2
exit 1
fi
}