More code style fixes (again)

This commit is contained in:
Laurent Goderre 2018-05-21 23:05:00 -04:00
parent d4c1e53573
commit fb8ac15c9c
5 changed files with 46 additions and 46 deletions

View File

@ -67,8 +67,8 @@ function get_variants() {
if [ ${#variantsfilter[@]} -gt 0 ]; then
for variant1 in "${availablevariants[@]}"; do
for variant2 in "${variantsfilter[@]}"; do
if [ "$variant1" = "$variant2" ]; then
variants+=("$variant1")
if [ "${variant1}" = "${variant2}" ]; then
variants+=("${variant1}")
fi
done
done
@ -100,11 +100,11 @@ function get_supported_arches() {
shift
# Get default supported arches
lines=$(grep "$variant" "$(dirname "${version}")"/architectures 2>/dev/null | cut -d' ' -f1)
lines=$(grep "${variant}" "$(dirname "${version}")"/architectures 2>/dev/null | cut -d' ' -f1)
# Get version specific supported architectures if there is specialized information
if [ -a "${version}"/architectures ]; then
lines=$(grep "$variant" "${version}"/architectures 2>/dev/null | cut -d' ' -f1)
lines=$(grep "${variant}" "${version}"/architectures 2>/dev/null | cut -d' ' -f1)
fi
while IFS='' read -r line; do
@ -123,12 +123,12 @@ function get_config() {
shift
local name
name=$1
name=${1}
shift
local value
value=$(grep "^$name" "${dir}/config" | sed -E 's/'"$name"'[[:space:]]*//')
echo "$value"
value=$(grep "^${name}" "${dir}/config" | sed -E 's/'"${name}"'[[:space:]]*//')
echo "${value}"
}
# Get available versions for a given path
@ -154,7 +154,7 @@ function get_versions() {
local subdirs
IFS=' ' read -ra subdirs <<<"$(get_versions "${dir#./}")"
for subdir in "${subdirs[@]}"; do
versions+=("$subdir")
versions+=("${subdir}")
done
elif [ -a "${dir}/Dockerfile" ]; then
versions+=("${dir#./}")

View File

@ -48,12 +48,12 @@ join() {
}
get_stub() {
local version="$1"
local version="${1}"
shift
IFS='/' read -ra versionparts <<<"${version}"
local stub
eval stub="$(join '_' "${versionparts[@]}" | awk -F. '{ print "$array_" $1 }')"
echo "$stub"
echo "${stub}"
}
for version in "${versions[@]}"; do
@ -85,7 +85,7 @@ for version in "${versions[@]}"; do
commit="$(fileCommit "${version}/${variant}")"
slash='/'
variantAliases=("${versionAliases[@]/%/-${variant//$slash/-}}")
variantAliases=("${versionAliases[@]/%/-${variant//${slash}/-}}")
variantAliases=("${variantAliases[@]//latest-/}")
# Get supported architectures for a specific version and variant.
# See details in function.sh

View File

@ -3,14 +3,14 @@
set -e
. functions.sh
if [ -z "$1" ]; then
COMMIT_ID="$TRAVIS_COMMIT"
COMMIT_MESSAGE="$TRAVIS_COMMIT_MESSAGE"
BRANCH_NAME="travis-$TRAVIS_BUILD_ID"
if [ -z "${1}" ]; then
COMMIT_ID="${TRAVIS_COMMIT}"
COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE}"
BRANCH_NAME="travis-${TRAVIS_BUILD_ID}"
GITHUB_USERNAME="nodejs-github-bot"
else
COMMIT_ID="$1"
COMMIT_MESSAGE="$(git show -s --format=%B "$1")"
COMMIT_ID="${1}"
COMMIT_MESSAGE="$(git show -s --format=%B "${COMMIT_ID}")"
BRANCH_NAME="travis-$(date +%s)"
if [[ "$(git remote get-url origin)" =~ github.com/([^/]*)/docker-node.git ]]; then
GITHUB_USERNAME="${BASH_REMATCH[1]}"
@ -41,18 +41,18 @@ function updated() {
)"
images_changed=$(git diff --name-only "${COMMIT_ID}".."${COMMIT_ID}"~1 "${versions[@]}")
if [ -z "$images_changed" ]; then
if [ -z "${images_changed}" ]; then
return 1
fi
return 0
}
function auth_header() {
echo "Authorization: token $GITHUB_API_TOKEN"
echo "Authorization: token ${GITHUB_API_TOKEN}"
}
function permission_check() {
if [ -z "$GITHUB_API_TOKEN" ]; then
if [ -z "${GITHUB_API_TOKEN}" ]; then
fatal "Environment variable \$GITHUB_API_TOKEN is missing or empty"
fi
@ -60,14 +60,14 @@ function permission_check() {
-s \
"https://api.github.com")"
if [ "$(echo "$auth" | jq -r .message)" = "Bad credentials" ]; then
if [ "$(echo "${auth}" | jq -r .message)" = "Bad credentials" ]; then
fatal "Authentication Failed! Invalid \$GITHUB_API_TOKEN"
fi
auth="$(curl -H "$(auth_header)" \
-s \
"https://api.github.com/repos/${ORIGIN_SLUG}/collaborators/${GITHUB_USERNAME}/permission")"
if [ "$(echo "$auth" | jq -r .message)" != "null" ]; then
if [ "$(echo "${auth}" | jq -r .message)" != "null" ]; then
fatal "\$GITHUB_API_TOKEN can't push to https://github.com/${ORIGIN_SLUG}.git"
fi
}
@ -98,7 +98,7 @@ function pr_payload() {
function comment_payload() {
local pr_url
pr_url="$1"
pr_url="${1}"
echo "{
'body': 'Created PR to the ${REPO_NAME} repo (${pr_url})'
}"
@ -116,7 +116,7 @@ if updated; then
stackbrew="$(./generate-stackbrew-library.sh)"
cd $gitpath
cd ${gitpath}
echo "${stackbrew}" >"${IMAGES_FILE}"
git checkout -b "${BRANCH_NAME}"
@ -126,7 +126,7 @@ if updated; then
info "Pushing..."
git push "https://${GITHUB_API_TOKEN}:x-oauth-basic@github.com/${ORIGIN_SLUG}.git" -f "${BRANCH_NAME}" 2>/dev/null || fatal "Error pushing the updated stackbrew"
cd - && rm -rf $gitpath
cd - && rm -rf ${gitpath}
info "Creating Pull request"
pr_response_payload="$(curl -H "$(auth_header)" \
@ -136,8 +136,8 @@ if updated; then
"https://api.github.com/repos/${UPSTREAM_SLUG}/pulls")"
url="$(echo "${pr_response_payload}" | jq -r .html_url)"
if [ "$url" != "null" ]; then
info "Pull request created at $url"
if [ "${url}" != "null" ]; then
info "Pull request created at ${url}"
if [ ! -z "${PR_NUMBER}" ]; then
comment_endpoint="https://api.github.com/repos/${DOCKER_SLUG}/issues/${PR_NUMBER}/comments"
@ -149,8 +149,8 @@ if updated; then
commit_response_payload="$(curl -H "$(auth_header)" \
-s \
-X POST \
-d "$(comment_payload "$url")" \
"$comment_endpoint")"
-d "$(comment_payload "${url}")" \
"${comment_endpoint}")"
if [ "$(echo "${commit_response_payload}" | jq -r .message)" != "null" ]; then
fatal "Error linking the pull request (${error_message})"

View File

@ -1,5 +1,5 @@
#!/bin/sh
if [ "$(node -e "process.stdout.write(process.versions.node)")" != "$1" ]; then
if [ "$(node -e "process.stdout.write(process.versions.node)")" != "${1}" ]; then
echo "Test for node failed!"
exit 1
fi

View File

@ -34,17 +34,17 @@ function in_versions_to_update() {
function update_node_version() {
local baseuri=$1
local baseuri=${1}
shift
local version=$1
local version=${1}
shift
local template=$1
local template=${1}
shift
local dockerfile=$1
local dockerfile=${1}
shift
local variant=""
if [ $# -eq 1 ]; then
variant=$1
variant=${1}
shift
fi
@ -58,7 +58,7 @@ function update_node_version() {
sed -Ei -e 's/^FROM (.*)/FROM '"${fromprefix}"'\1/' "${dockerfile}"
sed -Ei -e 's/^(ENV NODE_VERSION |FROM .*node:).*/\1'"${version}.${fullVersion:-0}"'/' "${dockerfile}"
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${yarnVersion}"'/' "$dockerfile"
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${yarnVersion}"'/' "${dockerfile}"
# shellcheck disable=SC1004
new_line=' \\\
@ -69,7 +69,7 @@ function update_node_version() {
while read -r line; do
pattern="\"\\$\\{$(echo "${key_type}" | tr '[:lower:]' '[:upper:]')_KEYS\\[@\\]\\}\""
sed -Ei -e "s/([ \\t]*)(${pattern})/\\1${line}${new_line}\\1\\2/" "${dockerfile}"
done <"keys/$key_type.keys"
done <"keys/${key_type}.keys"
sed -Ei -e "/${pattern}/d" "${dockerfile}"
done
@ -81,11 +81,11 @@ function update_node_version() {
}
function add_stage() {
local baseuri=$1
local baseuri=${1}
shift
local version=$1
local version=${1}
shift
local variant=$1
local variant=${1}
shift
echo '
@ -102,21 +102,21 @@ for version in "${versions[@]}"; do
# Skip "docs" and other non-docker directories
[ -f "${version}/Dockerfile" ] || continue
parentpath=$(dirname "$version")
versionnum=$(basename "$version")
baseuri=$(get_config "$parentpath" "baseuri")
update=$(in_versions_to_update "$version")
parentpath=$(dirname "${version}")
versionnum=$(basename "${version}")
baseuri=$(get_config "${parentpath}" "baseuri")
update=$(in_versions_to_update "${version}")
add_stage "${baseuri}" "${version}" "default"
if [ "${update}" -eq 0 ]; then
info "Updating version $version..."
info "Updating version ${version}..."
update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile.template" "${version}/Dockerfile" &
fi
# Get supported variants according the target architecture
# See details in function.sh
IFS=' ' read -ra variants <<<"$(get_variants "$parentpath")"
IFS=' ' read -ra variants <<<"$(get_variants "${parentpath}")"
for variant in "${variants[@]}"; do
# Skip non-docker directories