More code style fixes (again)
This commit is contained in:
parent
d4c1e53573
commit
fb8ac15c9c
16
functions.sh
16
functions.sh
|
@ -67,8 +67,8 @@ function get_variants() {
|
||||||
if [ ${#variantsfilter[@]} -gt 0 ]; then
|
if [ ${#variantsfilter[@]} -gt 0 ]; then
|
||||||
for variant1 in "${availablevariants[@]}"; do
|
for variant1 in "${availablevariants[@]}"; do
|
||||||
for variant2 in "${variantsfilter[@]}"; do
|
for variant2 in "${variantsfilter[@]}"; do
|
||||||
if [ "$variant1" = "$variant2" ]; then
|
if [ "${variant1}" = "${variant2}" ]; then
|
||||||
variants+=("$variant1")
|
variants+=("${variant1}")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
@ -100,11 +100,11 @@ function get_supported_arches() {
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# Get default supported arches
|
# 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
|
# Get version specific supported architectures if there is specialized information
|
||||||
if [ -a "${version}"/architectures ]; then
|
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
|
fi
|
||||||
|
|
||||||
while IFS='' read -r line; do
|
while IFS='' read -r line; do
|
||||||
|
@ -123,12 +123,12 @@ function get_config() {
|
||||||
shift
|
shift
|
||||||
|
|
||||||
local name
|
local name
|
||||||
name=$1
|
name=${1}
|
||||||
shift
|
shift
|
||||||
|
|
||||||
local value
|
local value
|
||||||
value=$(grep "^$name" "${dir}/config" | sed -E 's/'"$name"'[[:space:]]*//')
|
value=$(grep "^${name}" "${dir}/config" | sed -E 's/'"${name}"'[[:space:]]*//')
|
||||||
echo "$value"
|
echo "${value}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get available versions for a given path
|
# Get available versions for a given path
|
||||||
|
@ -154,7 +154,7 @@ function get_versions() {
|
||||||
local subdirs
|
local subdirs
|
||||||
IFS=' ' read -ra subdirs <<<"$(get_versions "${dir#./}")"
|
IFS=' ' read -ra subdirs <<<"$(get_versions "${dir#./}")"
|
||||||
for subdir in "${subdirs[@]}"; do
|
for subdir in "${subdirs[@]}"; do
|
||||||
versions+=("$subdir")
|
versions+=("${subdir}")
|
||||||
done
|
done
|
||||||
elif [ -a "${dir}/Dockerfile" ]; then
|
elif [ -a "${dir}/Dockerfile" ]; then
|
||||||
versions+=("${dir#./}")
|
versions+=("${dir#./}")
|
||||||
|
|
|
@ -48,12 +48,12 @@ join() {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_stub() {
|
get_stub() {
|
||||||
local version="$1"
|
local version="${1}"
|
||||||
shift
|
shift
|
||||||
IFS='/' read -ra versionparts <<<"${version}"
|
IFS='/' read -ra versionparts <<<"${version}"
|
||||||
local stub
|
local stub
|
||||||
eval stub="$(join '_' "${versionparts[@]}" | awk -F. '{ print "$array_" $1 }')"
|
eval stub="$(join '_' "${versionparts[@]}" | awk -F. '{ print "$array_" $1 }')"
|
||||||
echo "$stub"
|
echo "${stub}"
|
||||||
}
|
}
|
||||||
|
|
||||||
for version in "${versions[@]}"; do
|
for version in "${versions[@]}"; do
|
||||||
|
@ -85,7 +85,7 @@ for version in "${versions[@]}"; do
|
||||||
commit="$(fileCommit "${version}/${variant}")"
|
commit="$(fileCommit "${version}/${variant}")"
|
||||||
|
|
||||||
slash='/'
|
slash='/'
|
||||||
variantAliases=("${versionAliases[@]/%/-${variant//$slash/-}}")
|
variantAliases=("${versionAliases[@]/%/-${variant//${slash}/-}}")
|
||||||
variantAliases=("${variantAliases[@]//latest-/}")
|
variantAliases=("${variantAliases[@]//latest-/}")
|
||||||
# Get supported architectures for a specific version and variant.
|
# Get supported architectures for a specific version and variant.
|
||||||
# See details in function.sh
|
# See details in function.sh
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
set -e
|
set -e
|
||||||
. functions.sh
|
. functions.sh
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "${1}" ]; then
|
||||||
COMMIT_ID="$TRAVIS_COMMIT"
|
COMMIT_ID="${TRAVIS_COMMIT}"
|
||||||
COMMIT_MESSAGE="$TRAVIS_COMMIT_MESSAGE"
|
COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE}"
|
||||||
BRANCH_NAME="travis-$TRAVIS_BUILD_ID"
|
BRANCH_NAME="travis-${TRAVIS_BUILD_ID}"
|
||||||
GITHUB_USERNAME="nodejs-github-bot"
|
GITHUB_USERNAME="nodejs-github-bot"
|
||||||
else
|
else
|
||||||
COMMIT_ID="$1"
|
COMMIT_ID="${1}"
|
||||||
COMMIT_MESSAGE="$(git show -s --format=%B "$1")"
|
COMMIT_MESSAGE="$(git show -s --format=%B "${COMMIT_ID}")"
|
||||||
BRANCH_NAME="travis-$(date +%s)"
|
BRANCH_NAME="travis-$(date +%s)"
|
||||||
if [[ "$(git remote get-url origin)" =~ github.com/([^/]*)/docker-node.git ]]; then
|
if [[ "$(git remote get-url origin)" =~ github.com/([^/]*)/docker-node.git ]]; then
|
||||||
GITHUB_USERNAME="${BASH_REMATCH[1]}"
|
GITHUB_USERNAME="${BASH_REMATCH[1]}"
|
||||||
|
@ -41,18 +41,18 @@ function updated() {
|
||||||
)"
|
)"
|
||||||
images_changed=$(git diff --name-only "${COMMIT_ID}".."${COMMIT_ID}"~1 "${versions[@]}")
|
images_changed=$(git diff --name-only "${COMMIT_ID}".."${COMMIT_ID}"~1 "${versions[@]}")
|
||||||
|
|
||||||
if [ -z "$images_changed" ]; then
|
if [ -z "${images_changed}" ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function auth_header() {
|
function auth_header() {
|
||||||
echo "Authorization: token $GITHUB_API_TOKEN"
|
echo "Authorization: token ${GITHUB_API_TOKEN}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function permission_check() {
|
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"
|
fatal "Environment variable \$GITHUB_API_TOKEN is missing or empty"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -60,14 +60,14 @@ function permission_check() {
|
||||||
-s \
|
-s \
|
||||||
"https://api.github.com")"
|
"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"
|
fatal "Authentication Failed! Invalid \$GITHUB_API_TOKEN"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
auth="$(curl -H "$(auth_header)" \
|
auth="$(curl -H "$(auth_header)" \
|
||||||
-s \
|
-s \
|
||||||
"https://api.github.com/repos/${ORIGIN_SLUG}/collaborators/${GITHUB_USERNAME}/permission")"
|
"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"
|
fatal "\$GITHUB_API_TOKEN can't push to https://github.com/${ORIGIN_SLUG}.git"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ function pr_payload() {
|
||||||
|
|
||||||
function comment_payload() {
|
function comment_payload() {
|
||||||
local pr_url
|
local pr_url
|
||||||
pr_url="$1"
|
pr_url="${1}"
|
||||||
echo "{
|
echo "{
|
||||||
'body': 'Created PR to the ${REPO_NAME} repo (${pr_url})'
|
'body': 'Created PR to the ${REPO_NAME} repo (${pr_url})'
|
||||||
}"
|
}"
|
||||||
|
@ -116,7 +116,7 @@ if updated; then
|
||||||
|
|
||||||
stackbrew="$(./generate-stackbrew-library.sh)"
|
stackbrew="$(./generate-stackbrew-library.sh)"
|
||||||
|
|
||||||
cd $gitpath
|
cd ${gitpath}
|
||||||
|
|
||||||
echo "${stackbrew}" >"${IMAGES_FILE}"
|
echo "${stackbrew}" >"${IMAGES_FILE}"
|
||||||
git checkout -b "${BRANCH_NAME}"
|
git checkout -b "${BRANCH_NAME}"
|
||||||
|
@ -126,7 +126,7 @@ if updated; then
|
||||||
info "Pushing..."
|
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"
|
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"
|
info "Creating Pull request"
|
||||||
pr_response_payload="$(curl -H "$(auth_header)" \
|
pr_response_payload="$(curl -H "$(auth_header)" \
|
||||||
|
@ -136,8 +136,8 @@ if updated; then
|
||||||
"https://api.github.com/repos/${UPSTREAM_SLUG}/pulls")"
|
"https://api.github.com/repos/${UPSTREAM_SLUG}/pulls")"
|
||||||
|
|
||||||
url="$(echo "${pr_response_payload}" | jq -r .html_url)"
|
url="$(echo "${pr_response_payload}" | jq -r .html_url)"
|
||||||
if [ "$url" != "null" ]; then
|
if [ "${url}" != "null" ]; then
|
||||||
info "Pull request created at $url"
|
info "Pull request created at ${url}"
|
||||||
|
|
||||||
if [ ! -z "${PR_NUMBER}" ]; then
|
if [ ! -z "${PR_NUMBER}" ]; then
|
||||||
comment_endpoint="https://api.github.com/repos/${DOCKER_SLUG}/issues/${PR_NUMBER}/comments"
|
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)" \
|
commit_response_payload="$(curl -H "$(auth_header)" \
|
||||||
-s \
|
-s \
|
||||||
-X POST \
|
-X POST \
|
||||||
-d "$(comment_payload "$url")" \
|
-d "$(comment_payload "${url}")" \
|
||||||
"$comment_endpoint")"
|
"${comment_endpoint}")"
|
||||||
|
|
||||||
if [ "$(echo "${commit_response_payload}" | jq -r .message)" != "null" ]; then
|
if [ "$(echo "${commit_response_payload}" | jq -r .message)" != "null" ]; then
|
||||||
fatal "Error linking the pull request (${error_message})"
|
fatal "Error linking the pull request (${error_message})"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/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!"
|
echo "Test for node failed!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
32
update.sh
32
update.sh
|
@ -34,17 +34,17 @@ function in_versions_to_update() {
|
||||||
|
|
||||||
function update_node_version() {
|
function update_node_version() {
|
||||||
|
|
||||||
local baseuri=$1
|
local baseuri=${1}
|
||||||
shift
|
shift
|
||||||
local version=$1
|
local version=${1}
|
||||||
shift
|
shift
|
||||||
local template=$1
|
local template=${1}
|
||||||
shift
|
shift
|
||||||
local dockerfile=$1
|
local dockerfile=${1}
|
||||||
shift
|
shift
|
||||||
local variant=""
|
local variant=""
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
variant=$1
|
variant=${1}
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ function update_node_version() {
|
||||||
|
|
||||||
sed -Ei -e 's/^FROM (.*)/FROM '"${fromprefix}"'\1/' "${dockerfile}"
|
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 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
|
# shellcheck disable=SC1004
|
||||||
new_line=' \\\
|
new_line=' \\\
|
||||||
|
@ -69,7 +69,7 @@ function update_node_version() {
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
pattern="\"\\$\\{$(echo "${key_type}" | tr '[:lower:]' '[:upper:]')_KEYS\\[@\\]\\}\""
|
pattern="\"\\$\\{$(echo "${key_type}" | tr '[:lower:]' '[:upper:]')_KEYS\\[@\\]\\}\""
|
||||||
sed -Ei -e "s/([ \\t]*)(${pattern})/\\1${line}${new_line}\\1\\2/" "${dockerfile}"
|
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}"
|
sed -Ei -e "/${pattern}/d" "${dockerfile}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -81,11 +81,11 @@ function update_node_version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_stage() {
|
function add_stage() {
|
||||||
local baseuri=$1
|
local baseuri=${1}
|
||||||
shift
|
shift
|
||||||
local version=$1
|
local version=${1}
|
||||||
shift
|
shift
|
||||||
local variant=$1
|
local variant=${1}
|
||||||
shift
|
shift
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
@ -102,21 +102,21 @@ for version in "${versions[@]}"; do
|
||||||
# Skip "docs" and other non-docker directories
|
# Skip "docs" and other non-docker directories
|
||||||
[ -f "${version}/Dockerfile" ] || continue
|
[ -f "${version}/Dockerfile" ] || continue
|
||||||
|
|
||||||
parentpath=$(dirname "$version")
|
parentpath=$(dirname "${version}")
|
||||||
versionnum=$(basename "$version")
|
versionnum=$(basename "${version}")
|
||||||
baseuri=$(get_config "$parentpath" "baseuri")
|
baseuri=$(get_config "${parentpath}" "baseuri")
|
||||||
update=$(in_versions_to_update "$version")
|
update=$(in_versions_to_update "${version}")
|
||||||
|
|
||||||
add_stage "${baseuri}" "${version}" "default"
|
add_stage "${baseuri}" "${version}" "default"
|
||||||
|
|
||||||
if [ "${update}" -eq 0 ]; then
|
if [ "${update}" -eq 0 ]; then
|
||||||
info "Updating version $version..."
|
info "Updating version ${version}..."
|
||||||
update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile.template" "${version}/Dockerfile" &
|
update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile.template" "${version}/Dockerfile" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get supported variants according the target architecture
|
# Get supported variants according the target architecture
|
||||||
# See details in function.sh
|
# See details in function.sh
|
||||||
IFS=' ' read -ra variants <<<"$(get_variants "$parentpath")"
|
IFS=' ' read -ra variants <<<"$(get_variants "${parentpath}")"
|
||||||
|
|
||||||
for variant in "${variants[@]}"; do
|
for variant in "${variants[@]}"; do
|
||||||
# Skip non-docker directories
|
# Skip non-docker directories
|
||||||
|
|
Loading…
Reference in New Issue