Skip to content

Commit fb8ac15

Browse files
More code style fixes (again)
1 parent d4c1e53 commit fb8ac15

File tree

5 files changed

+46
-46
lines changed

5 files changed

+46
-46
lines changed

functions.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ function get_variants() {
6767
if [ ${#variantsfilter[@]} -gt 0 ]; then
6868
for variant1 in "${availablevariants[@]}"; do
6969
for variant2 in "${variantsfilter[@]}"; do
70-
if [ "$variant1" = "$variant2" ]; then
71-
variants+=("$variant1")
70+
if [ "${variant1}" = "${variant2}" ]; then
71+
variants+=("${variant1}")
7272
fi
7373
done
7474
done
@@ -100,11 +100,11 @@ function get_supported_arches() {
100100
shift
101101

102102
# Get default supported arches
103-
lines=$(grep "$variant" "$(dirname "${version}")"/architectures 2>/dev/null | cut -d' ' -f1)
103+
lines=$(grep "${variant}" "$(dirname "${version}")"/architectures 2>/dev/null | cut -d' ' -f1)
104104

105105
# Get version specific supported architectures if there is specialized information
106106
if [ -a "${version}"/architectures ]; then
107-
lines=$(grep "$variant" "${version}"/architectures 2>/dev/null | cut -d' ' -f1)
107+
lines=$(grep "${variant}" "${version}"/architectures 2>/dev/null | cut -d' ' -f1)
108108
fi
109109

110110
while IFS='' read -r line; do
@@ -123,12 +123,12 @@ function get_config() {
123123
shift
124124

125125
local name
126-
name=$1
126+
name=${1}
127127
shift
128128

129129
local value
130-
value=$(grep "^$name" "${dir}/config" | sed -E 's/'"$name"'[[:space:]]*//')
131-
echo "$value"
130+
value=$(grep "^${name}" "${dir}/config" | sed -E 's/'"${name}"'[[:space:]]*//')
131+
echo "${value}"
132132
}
133133

134134
# Get available versions for a given path
@@ -154,7 +154,7 @@ function get_versions() {
154154
local subdirs
155155
IFS=' ' read -ra subdirs <<<"$(get_versions "${dir#./}")"
156156
for subdir in "${subdirs[@]}"; do
157-
versions+=("$subdir")
157+
versions+=("${subdir}")
158158
done
159159
elif [ -a "${dir}/Dockerfile" ]; then
160160
versions+=("${dir#./}")

generate-stackbrew-library.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ join() {
4848
}
4949

5050
get_stub() {
51-
local version="$1"
51+
local version="${1}"
5252
shift
5353
IFS='/' read -ra versionparts <<<"${version}"
5454
local stub
5555
eval stub="$(join '_' "${versionparts[@]}" | awk -F. '{ print "$array_" $1 }')"
56-
echo "$stub"
56+
echo "${stub}"
5757
}
5858

5959
for version in "${versions[@]}"; do
@@ -85,7 +85,7 @@ for version in "${versions[@]}"; do
8585
commit="$(fileCommit "${version}/${variant}")"
8686

8787
slash='/'
88-
variantAliases=("${versionAliases[@]/%/-${variant//$slash/-}}")
88+
variantAliases=("${versionAliases[@]/%/-${variant//${slash}/-}}")
8989
variantAliases=("${variantAliases[@]//latest-/}")
9090
# Get supported architectures for a specific version and variant.
9191
# See details in function.sh

generate-stackbrew-pr.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
set -e
44
. functions.sh
55

6-
if [ -z "$1" ]; then
7-
COMMIT_ID="$TRAVIS_COMMIT"
8-
COMMIT_MESSAGE="$TRAVIS_COMMIT_MESSAGE"
9-
BRANCH_NAME="travis-$TRAVIS_BUILD_ID"
6+
if [ -z "${1}" ]; then
7+
COMMIT_ID="${TRAVIS_COMMIT}"
8+
COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE}"
9+
BRANCH_NAME="travis-${TRAVIS_BUILD_ID}"
1010
GITHUB_USERNAME="nodejs-github-bot"
1111
else
12-
COMMIT_ID="$1"
13-
COMMIT_MESSAGE="$(git show -s --format=%B "$1")"
12+
COMMIT_ID="${1}"
13+
COMMIT_MESSAGE="$(git show -s --format=%B "${COMMIT_ID}")"
1414
BRANCH_NAME="travis-$(date +%s)"
1515
if [[ "$(git remote get-url origin)" =~ github.com/([^/]*)/docker-node.git ]]; then
1616
GITHUB_USERNAME="${BASH_REMATCH[1]}"
@@ -41,33 +41,33 @@ function updated() {
4141
)"
4242
images_changed=$(git diff --name-only "${COMMIT_ID}".."${COMMIT_ID}"~1 "${versions[@]}")
4343

44-
if [ -z "$images_changed" ]; then
44+
if [ -z "${images_changed}" ]; then
4545
return 1
4646
fi
4747
return 0
4848
}
4949

5050
function auth_header() {
51-
echo "Authorization: token $GITHUB_API_TOKEN"
51+
echo "Authorization: token ${GITHUB_API_TOKEN}"
5252
}
5353

5454
function permission_check() {
55-
if [ -z "$GITHUB_API_TOKEN" ]; then
55+
if [ -z "${GITHUB_API_TOKEN}" ]; then
5656
fatal "Environment variable \$GITHUB_API_TOKEN is missing or empty"
5757
fi
5858

5959
auth="$(curl -H "$(auth_header)" \
6060
-s \
6161
"https://api.github.com")"
6262

63-
if [ "$(echo "$auth" | jq -r .message)" = "Bad credentials" ]; then
63+
if [ "$(echo "${auth}" | jq -r .message)" = "Bad credentials" ]; then
6464
fatal "Authentication Failed! Invalid \$GITHUB_API_TOKEN"
6565
fi
6666

6767
auth="$(curl -H "$(auth_header)" \
6868
-s \
6969
"https://api.github.com/repos/${ORIGIN_SLUG}/collaborators/${GITHUB_USERNAME}/permission")"
70-
if [ "$(echo "$auth" | jq -r .message)" != "null" ]; then
70+
if [ "$(echo "${auth}" | jq -r .message)" != "null" ]; then
7171
fatal "\$GITHUB_API_TOKEN can't push to https://github.com/${ORIGIN_SLUG}.git"
7272
fi
7373
}
@@ -98,7 +98,7 @@ function pr_payload() {
9898

9999
function comment_payload() {
100100
local pr_url
101-
pr_url="$1"
101+
pr_url="${1}"
102102
echo "{
103103
'body': 'Created PR to the ${REPO_NAME} repo (${pr_url})'
104104
}"
@@ -116,7 +116,7 @@ if updated; then
116116

117117
stackbrew="$(./generate-stackbrew-library.sh)"
118118

119-
cd $gitpath
119+
cd ${gitpath}
120120

121121
echo "${stackbrew}" >"${IMAGES_FILE}"
122122
git checkout -b "${BRANCH_NAME}"
@@ -126,7 +126,7 @@ if updated; then
126126
info "Pushing..."
127127
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"
128128

129-
cd - && rm -rf $gitpath
129+
cd - && rm -rf ${gitpath}
130130

131131
info "Creating Pull request"
132132
pr_response_payload="$(curl -H "$(auth_header)" \
@@ -136,8 +136,8 @@ if updated; then
136136
"https://api.github.com/repos/${UPSTREAM_SLUG}/pulls")"
137137

138138
url="$(echo "${pr_response_payload}" | jq -r .html_url)"
139-
if [ "$url" != "null" ]; then
140-
info "Pull request created at $url"
139+
if [ "${url}" != "null" ]; then
140+
info "Pull request created at ${url}"
141141

142142
if [ ! -z "${PR_NUMBER}" ]; then
143143
comment_endpoint="https://api.github.com/repos/${DOCKER_SLUG}/issues/${PR_NUMBER}/comments"
@@ -149,8 +149,8 @@ if updated; then
149149
commit_response_payload="$(curl -H "$(auth_header)" \
150150
-s \
151151
-X POST \
152-
-d "$(comment_payload "$url")" \
153-
"$comment_endpoint")"
152+
-d "$(comment_payload "${url}")" \
153+
"${comment_endpoint}")"
154154

155155
if [ "$(echo "${commit_response_payload}" | jq -r .message)" != "null" ]; then
156156
fatal "Error linking the pull request (${error_message})"

test-image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
if [ "$(node -e "process.stdout.write(process.versions.node)")" != "$1" ]; then
2+
if [ "$(node -e "process.stdout.write(process.versions.node)")" != "${1}" ]; then
33
echo "Test for node failed!"
44
exit 1
55
fi

update.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ function in_versions_to_update() {
3434

3535
function update_node_version() {
3636

37-
local baseuri=$1
37+
local baseuri=${1}
3838
shift
39-
local version=$1
39+
local version=${1}
4040
shift
41-
local template=$1
41+
local template=${1}
4242
shift
43-
local dockerfile=$1
43+
local dockerfile=${1}
4444
shift
4545
local variant=""
4646
if [ $# -eq 1 ]; then
47-
variant=$1
47+
variant=${1}
4848
shift
4949
fi
5050

@@ -58,7 +58,7 @@ function update_node_version() {
5858

5959
sed -Ei -e 's/^FROM (.*)/FROM '"${fromprefix}"'\1/' "${dockerfile}"
6060
sed -Ei -e 's/^(ENV NODE_VERSION |FROM .*node:).*/\1'"${version}.${fullVersion:-0}"'/' "${dockerfile}"
61-
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${yarnVersion}"'/' "$dockerfile"
61+
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${yarnVersion}"'/' "${dockerfile}"
6262

6363
# shellcheck disable=SC1004
6464
new_line=' \\\
@@ -69,7 +69,7 @@ function update_node_version() {
6969
while read -r line; do
7070
pattern="\"\\$\\{$(echo "${key_type}" | tr '[:lower:]' '[:upper:]')_KEYS\\[@\\]\\}\""
7171
sed -Ei -e "s/([ \\t]*)(${pattern})/\\1${line}${new_line}\\1\\2/" "${dockerfile}"
72-
done <"keys/$key_type.keys"
72+
done <"keys/${key_type}.keys"
7373
sed -Ei -e "/${pattern}/d" "${dockerfile}"
7474
done
7575

@@ -81,11 +81,11 @@ function update_node_version() {
8181
}
8282

8383
function add_stage() {
84-
local baseuri=$1
84+
local baseuri=${1}
8585
shift
86-
local version=$1
86+
local version=${1}
8787
shift
88-
local variant=$1
88+
local variant=${1}
8989
shift
9090

9191
echo '
@@ -102,21 +102,21 @@ for version in "${versions[@]}"; do
102102
# Skip "docs" and other non-docker directories
103103
[ -f "${version}/Dockerfile" ] || continue
104104

105-
parentpath=$(dirname "$version")
106-
versionnum=$(basename "$version")
107-
baseuri=$(get_config "$parentpath" "baseuri")
108-
update=$(in_versions_to_update "$version")
105+
parentpath=$(dirname "${version}")
106+
versionnum=$(basename "${version}")
107+
baseuri=$(get_config "${parentpath}" "baseuri")
108+
update=$(in_versions_to_update "${version}")
109109

110110
add_stage "${baseuri}" "${version}" "default"
111111

112112
if [ "${update}" -eq 0 ]; then
113-
info "Updating version $version..."
113+
info "Updating version ${version}..."
114114
update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile.template" "${version}/Dockerfile" &
115115
fi
116116

117117
# Get supported variants according the target architecture
118118
# See details in function.sh
119-
IFS=' ' read -ra variants <<<"$(get_variants "$parentpath")"
119+
IFS=' ' read -ra variants <<<"$(get_variants "${parentpath}")"
120120

121121
for variant in "${variants[@]}"; do
122122
# Skip non-docker directories

0 commit comments

Comments
 (0)