Skip to content

Commit 43adb03

Browse files
author
Alfonso Acosta
authored
Merge pull request #2068 from kinvolk/iaguis/fix-lint
Fix linter errors
2 parents 75ed573 + 5cb5c7d commit 43adb03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+855
-751
lines changed

backend/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ RUN go get -tags netgo \
99
github.com/fzipp/gocyclo \
1010
github.com/golang/lint/golint \
1111
github.com/kisielk/errcheck \
12+
gopkg.in/mvdan/sh.v1/cmd/shfmt \
1213
github.com/mjibson/esc \
1314
github.com/client9/misspell/cmd/misspell && \
1415
rm -rf /go/pkg/ /go/src/

backend/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ SCOPE_SRC=$GOPATH/src/github.com/weaveworks/scope
1111
# will have awkward ownership. So we switch to a user with the
1212
# same user and group IDs as source directory. We have to set a
1313
# few things up so that sudo works without complaining later on.
14-
uid=$(stat --format="%u" $SCOPE_SRC)
15-
gid=$(stat --format="%g" $SCOPE_SRC)
14+
uid=$(stat --format="%u" "$SCOPE_SRC")
15+
gid=$(stat --format="%g" "$SCOPE_SRC")
1616
echo "weave:x:$uid:$gid::$SCOPE_SRC:/bin/sh" >>/etc/passwd
1717
echo "weave:*:::::::" >>/etc/shadow
1818
echo "weave ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers

bin/release

Lines changed: 47 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ DOCKERHUB_USER=${DOCKERHUB_USER:-weaveworks}
88
RELEASE_NAME=${RELEASE_NAME:-"Weave Scope"}
99
RELEASE_DESCRIPTION=${RELEASE_DESCRIPTION:-"Container Visibility"}
1010

11-
PWD=`pwd`
12-
WC="wc"
13-
# Use GNU wc on Darwin
14-
case $OSTYPE in darwin*) WC="gwc" ;; esac
11+
PWD=$(pwd)
1512

1613
infer_release_type() {
17-
if echo $1 | grep -qE '^v[0-9]+\.[0-9]+\.0+$' ; then
14+
if echo "$1" | grep -qE '^v[0-9]+\.[0-9]+\.0+$'; then
1815
echo MAINLINE
19-
elif echo $1 | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$' ; then
16+
elif echo "$1" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
2017
echo BRANCH
2118
else
2219
echo PRERELEASE
@@ -26,10 +23,12 @@ infer_release_type() {
2623
setup() {
2724
# Ensure we have exactly one annotated tag pointing at HEAD
2825
HEAD_TAGS=$(git tag --points-at HEAD)
29-
TAG_COUNT=$(echo $(echo $HEAD_TAGS | wc -w)) # mac hack
26+
# shellcheck disable=SC2116
27+
# shellcheck disable=SC2005
28+
TAG_COUNT=$(echo "$(echo "$HEAD_TAGS" | wc -w)") # mac hack
3029
case $TAG_COUNT in
3130
1)
32-
if [ $HEAD_TAGS != "latest_release" ] ; then
31+
if [ "$HEAD_TAGS" != "latest_release" ]; then
3332
LATEST_TAG=$HEAD_TAGS
3433
else
3534
echo "Cannot determine version - latest_release points at HEAD" >&2
@@ -42,21 +41,21 @@ setup() {
4241
;;
4342
*)
4443
echo "Cannot determine version - multiple tags point at HEAD:" >&2
45-
for TAG in $HEAD_TAGS ; do
44+
for TAG in $HEAD_TAGS; do
4645
echo -e "\t$TAG" >&2
4746
done
4847
exit 1
4948
;;
5049
esac
5150

52-
RELEASE_TYPE=$(infer_release_type $LATEST_TAG)
51+
RELEASE_TYPE=$(infer_release_type "$LATEST_TAG")
5352
echo "== Inferred release type $RELEASE_TYPE from tag $LATEST_TAG"
5453

55-
LATEST_TAG_SHA=$(git rev-parse $LATEST_TAG)
56-
LATEST_TAG_COMMIT_SHA=$(git rev-list -1 $LATEST_TAG)
54+
LATEST_TAG_SHA=$(git rev-parse "$LATEST_TAG")
55+
LATEST_TAG_COMMIT_SHA=$(git rev-list -1 "$LATEST_TAG")
5756
LATEST_RELEASE_SHA=$(git rev-parse latest_release)
5857
LATEST_RELEASE_COMMIT_SHA=$(git rev-list -1 latest_release)
59-
if [ "$RELEASE_TYPE" != 'PRERELEASE' ] ; then
58+
if [ "$RELEASE_TYPE" != 'PRERELEASE' ]; then
6059
VERSION=${LATEST_TAG#v}
6160
else
6261
VERSION=${LATEST_TAG}
@@ -69,20 +68,20 @@ build() {
6968
setup
7069

7170
echo "== Clone repo at $LATEST_TAG for version $VERSION"
72-
if [ -d $RELEASE_DIR ]; then
71+
if [ -d "$RELEASE_DIR" ]; then
7372
echo -e "\u2757 Release directory $RELEASE_DIR already exists, you may want to" >&2
7473
echo -e "\trm -rf $RELEASE_DIR" >&2
7574
exit 1
7675
fi
7776

7877
## Clone the repo at the tag and go there
7978
mkdir -p releases
80-
git clone -q -b $LATEST_TAG . $RELEASE_DIR 2>/dev/null
81-
cd $RELEASE_DIR
79+
git clone -q -b "$LATEST_TAG" . "$RELEASE_DIR" 2>/dev/null
80+
cd "$RELEASE_DIR"
8281

8382
## Check that the top changelog entry is this version
84-
if ! latest_changelog=$(perl -nle'print $& if m{(?<=^## Release ).*}' ./CHANGELOG.md | head -1) || \
85-
! [ `echo "$latest_changelog" = "$VERSION"` ]; then
83+
if ! latest_changelog=$(perl -nle'print $& if m{(?<=^## Release ).*}' ./CHANGELOG.md | head -1) \
84+
|| ! [ "$latest_changelog" = "$VERSION" ]; then
8685
echo -e "\u2757 Latest changelog entry \"$latest_changelog\" does not match the release version $VERSION" >&2
8786
exit 1
8887
fi
@@ -93,9 +92,9 @@ build() {
9392
## Inject the version numbers and build the distributables
9493
## (library versions?)
9594
sed -i.tmp "s/SCRIPT_VERSION=\"[^\"]*\"/SCRIPT_VERSION=\"$VERSION\"/" ./scope
96-
make SUDO=$SUDO SCOPE_VERSION=$VERSION DOCKERHUB_USER=$DOCKERHUB_USER
95+
make SUDO="$SUDO" SCOPE_VERSION="$VERSION" DOCKERHUB_USER="$DOCKERHUB_USER"
9796

98-
if make tests SUDO=$SUDO; then
97+
if make tests SUDO="$SUDO"; then
9998
echo -e '\u2713 Tests pass'
10099
else
101100
echo -e "\u2757 Tests failed, probably best not publish this one" >&2
@@ -110,18 +109,18 @@ build() {
110109
#fi
111110

112111
echo -e '\u2713 Build OK'
113-
echo '** Release artefacts in' $RELEASE_DIR
112+
echo '** Release artefacts in' "$RELEASE_DIR"
114113
}
115114

116115
draft() {
117116
setup
118117

119-
cd $PWD/$RELEASE_DIR
118+
cd "$PWD"/"$RELEASE_DIR"
120119

121120
echo "== Sanity checks"
122121

123122
## Check that the tag exists by looking at github
124-
if ! curl -sSf https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_TAG_SHA >/dev/null 2>&1; then
123+
if ! curl -sSf "https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_TAG_SHA" >/dev/null 2>&1; then
125124
echo -e "\u2757 Tag $LATEST_TAG is not on GitHub, or is not the same as the local tag" >&2
126125
echo -e "\thttps://github.com/$GITHUB_USER/scope/tags" >&2
127126
echo "You may need to" >&2
@@ -133,31 +132,31 @@ draft() {
133132

134133
## Check that the version does not already exist by looking at github
135134
## releases
136-
if github-release info --user $GITHUB_USER --repo scope --tag $LATEST_TAG >/dev/null 2>&1; then
135+
if github-release info --user "$GITHUB_USER" --repo scope --tag "$LATEST_TAG" >/dev/null 2>&1; then
137136
echo -e "\u2757 Release $LATEST_TAG already exists on GitHub" >&2
138137
echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" >&2
139138
exit 1
140139
fi
141140

142-
echo '** Sanity checks OK for publishing tag' $LATEST_TAG as $DOCKERHUB_USER/scope:$VERSION
141+
echo '** Sanity checks OK for publishing tag' "$LATEST_TAG" as "$DOCKERHUB_USER/scope:$VERSION"
143142

144143
RELEASE_ARGS="--draft"
145-
if [ "$RELEASE_TYPE" = 'PRERELEASE' ] ; then
144+
if [ "$RELEASE_TYPE" = 'PRERELEASE' ]; then
146145
RELEASE_ARGS="$RELEASE_ARGS --pre-release"
147146
fi
148147

149148
echo "== Creating GitHub release $RELEASE_ARGS $RELEASE_NAME $VERSION"
150-
github-release release $RELEASE_ARGS \
151-
--user $GITHUB_USER \
149+
github-release release "$RELEASE_ARGS" \
150+
--user "$GITHUB_USER" \
152151
--repo scope \
153-
--tag $LATEST_TAG \
152+
--tag "$LATEST_TAG" \
154153
--name "$RELEASE_NAME $VERSION" \
155154
--description "$RELEASE_DESCRIPTION"
156155

157156
github-release upload \
158-
--user $GITHUB_USER \
157+
--user "$GITHUB_USER" \
159158
--repo scope \
160-
--tag $LATEST_TAG \
159+
--tag "$LATEST_TAG" \
161160
--name "scope" \
162161
--file "./scope"
163162

@@ -167,76 +166,71 @@ draft() {
167166

168167
publish() {
169168
setup
170-
cd $PWD/$RELEASE_DIR
169+
cd "$PWD"/"$RELEASE_DIR"
171170

172-
UPDATE_LATEST=false
173-
if [ "$RELEASE_TYPE" = 'MAINLINE' ] ; then
174-
UPDATE_LATEST=true
175-
fi
176-
177-
if [ "$RELEASE_TYPE" = 'PRERELEASE' ] ; then
171+
if [ "$RELEASE_TYPE" = 'PRERELEASE' ]; then
178172
echo "== Tagging and pushing images on docker hub as user $DOCKERHUB_USER"
179-
$SUDO docker tag -f $DOCKERHUB_USER/scope $DOCKERHUB_USER/scope:$VERSION
180-
$SUDO docker push $DOCKERHUB_USER/scope:$VERSION
173+
$SUDO docker tag -f "$DOCKERHUB_USER"/scope "$DOCKERHUB_USER/scope:$VERSION"
174+
$SUDO docker push "$DOCKERHUB_USER/scope:$VERSION"
181175
echo "** Docker images tagged and pushed"
182176

183177
echo "== Publishing pre-release on GitHub"
184178

185179
github-release publish \
186-
--user $GITHUB_USER \
180+
--user "$GITHUB_USER" \
187181
--repo scope \
188-
--tag $LATEST_TAG
182+
--tag "$LATEST_TAG"
189183

190184
echo "** Pre-release $RELEASE_NAME $VERSION published at"
191185
echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG"
192186
else
193187
echo "== Sanity checks"
194-
if ! [ "$LATEST_TAG_COMMIT_SHA" == "$LATEST_RELEASE_COMMIT_SHA" ] ; then
188+
if ! [ "$LATEST_TAG_COMMIT_SHA" == "$LATEST_RELEASE_COMMIT_SHA" ]; then
195189
echo -e "\u2757 The tag latest_release does not point to the same commit as $LATEST_TAG" >&2
196190
echo "You may need to" >&2
197191
echo -e "\tgit tag -af latest_release $LATEST_TAG" >&2
198192
exit 1
199193
fi
200194

201195
## Check that the 'latest_release' tag exists by looking at github
202-
if ! curl -sSf https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_RELEASE_SHA >/dev/null 2>&1; then
196+
if ! curl -sSf "https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_RELEASE_SHA" >/dev/null 2>&1; then
203197
echo -e "\u2757 Tag latest_release is not on GitHub, or is not the same as the local tag" >&2
204198
echo -e "\thttps://github.com/$GITHUB_USER/scope/tags" >&2
205199
echo "You may need to" >&2
206200
echo -e "\tgit push -f git@github.com:$GITHUB_USER/scope latest_release" >&2
207201
exit 1
208202
fi
209-
echo '** Sanity checks OK for publishing tag' $LATEST_TAG as $DOCKERHUB_USER/scope:$VERSION
203+
echo '** Sanity checks OK for publishing tag' "$LATEST_TAG" as "$DOCKERHUB_USER/scope:$VERSION"
210204

211205
echo "== Tagging and pushing images on docker hub as user $DOCKERHUB_USER"
212-
$SUDO docker tag -f $DOCKERHUB_USER/scope $DOCKERHUB_USER/scope:$VERSION
213-
$SUDO docker push $DOCKERHUB_USER/scope:$VERSION
206+
$SUDO docker tag -f "$DOCKERHUB_USER"/scope "$DOCKERHUB_USER/scope:$VERSION"
207+
$SUDO docker push "$DOCKERHUB_USER"/scope:$"VERSION"
214208
echo "** Docker images tagged and pushed"
215209

216210
echo "== Publishing release on GitHub"
217211

218212
github-release publish \
219-
--user $GITHUB_USER \
213+
--user "$GITHUB_USER" \
220214
--repo scope \
221-
--tag $LATEST_TAG
215+
--tag "$LATEST_TAG"
222216

223-
if github-release info --user $GITHUB_USER --repo scope \
217+
if github-release info --user "$GITHUB_USER" --repo scope \
224218
--tag latest_release >/dev/null 2>&1; then
225219
github-release delete \
226-
--user $GITHUB_USER \
220+
--user "$GITHUB_USER" \
227221
--repo scope \
228222
--tag latest_release
229223
fi
230224

231225
github-release release \
232-
--user $GITHUB_USER \
226+
--user "$GITHUB_USER" \
233227
--repo scope \
234228
--tag latest_release \
235229
--name "$RELEASE_NAME latest ($VERSION)" \
236230
--description "[Release Notes](https://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG)"
237231

238232
github-release upload \
239-
--user $GITHUB_USER \
233+
--user "$GITHUB_USER" \
240234
--repo scope \
241235
--tag latest_release \
242236
--name "scope" \

bin/setup-circleci-secrets

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ set -eu
55
# openssl enc -in do-setup-circleci-secrets.orig -out setup-circleci-secrets.orig -e -aes256 -pass stdin
66
# openssl base64 < setup-circleci-secrets.orig
77

8-
openssl base64 -d << EOF \
9-
| openssl enc \
8+
openssl base64 -d <<EOF | openssl enc \
109
-out bin/do-setup-circleci-secrets \
11-
-d -aes256 -pass pass:$1
10+
-d -aes256 -pass pass:"$1"
1211
U2FsdGVkX193YHZJXNzxU9GqigQaXWrA0AKd+BIjRcx7bmmKn/zSgOv+FfApRRjn
1312
KGBd2ulZw9CwsftX0HWHzVdtpgqbJUW+FEma8eNldau4/f+T+yWTVpCNQXGc3DvB
1413
cWYhmkoTfGWmI2v/0/Bv2TYkw7MAfjCocdluFAv7sSvYnSgIjoYxD4XXkTjLWy1P

client/test/run-jankie.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ echo "Testing $COMMIT on $DATE"
3737
# ../../scope launch
3838
# sleep 5
3939

40-
COMMIT="$COMMIT" DATE=$DATE HOST=$HOST DEBUG=scope* node ./perfjankie/main.js
40+
COMMIT="$COMMIT" DATE=$DATE HOST=$HOST DEBUG="scope*" node ./perfjankie/main.js

docker/entrypoint.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22

33
mkdir -p /var/run/weave
44

5-
for arg in $@; do
5+
for arg in "$@"; do
66
case "$arg" in
7-
--no-app|--probe-only|--service-token*|--probe.token*)
7+
--no-app | --probe-only | --service-token* | --probe.token*)
88
touch /etc/service/app/down
99
;;
10-
--no-probe|--app-only)
10+
--no-probe | --app-only)
1111
touch /etc/service/probe/down
1212
;;
1313
esac
1414
done
1515

16+
# shellcheck disable=SC2034
1617
ARGS=("$@")
1718

18-
typeset -p ARGS >/var/run/weave/scope-app.args
19-
typeset -p ARGS >/var/run/weave/scope-probe.args
19+
declare -p ARGS >/var/run/weave/scope-app.args
20+
# shellcheck disable=SC2034
21+
declare -p ARGS >/var/run/weave/scope-probe.args
2022

2123
exec /home/weave/runsvinit

docker/run-app

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

3+
# shellcheck disable=SC1091
34
source /var/run/weave/scope-app.args
4-
5+
56
exec -a scope-app /home/weave/scope --mode app "${ARGS[@]}"

docker/run-probe

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

3+
# shellcheck disable=SC1091
34
source /var/run/weave/scope-probe.args
45

56
exec -a scope-probe /home/weave/scope --mode probe "${ARGS[@]}"

extras/build_on_circle.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
set -e
44

5-
./in_parallel.sh "make RM=" $(find . -maxdepth 2 -name *.go -printf "%h\n" | sort -u | sed -n 's/\.\/\(.*\)/\1\/\1/p')
5+
./in_parallel.sh "make RM=" "$(find . -maxdepth 2 -name "./*.go" -printf "%h\n" | sort -u | sed -n 's/\.\/\(.*\)/\1\/\1/p')"

extras/dialer/dialer

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
#!/bin/bash
22
set -eu
33
if [ $# -lt 1 ]; then
4-
echo "Usage: $0 <ip:port> [<max_dialer>]" >&2
5-
exit 1
4+
echo "Usage: $0 <ip:port> [<max_dialer>]" >&2
5+
exit 1
66
fi
77

88
readonly addr=$1
99
readonly max_dialer=${2:-50}
1010

1111
dialer=()
12+
# shellcheck disable=SC2154
1213
trap 'echo -n "stopping ... "; for c in "${dialer[@]}"; do docker rm -f "$c" >/dev/null; done; echo "done"' EXIT
1314

1415
while true; do
15-
rand=$(( ( RANDOM % max_dialer ) + 1 ))
16-
dialer+=("$(docker run -d dialer /go/bin/dialer connect "$addr" "$rand")")
16+
rand=$(((RANDOM % max_dialer) + 1))
17+
dialer+=("$(docker run -d dialer /go/bin/dialer connect "$addr" "$rand")")
1718

18-
if [ ${#dialer[@]} -gt "$max_dialer" ]; then
19-
container=${dialer[$rand]}
20-
docker rm -f "$container" >/dev/null &
21-
unset dialer[$rand]
22-
dialer=("${dialer[@]}")
23-
fi
19+
if [ ${#dialer[@]} -gt "$max_dialer" ]; then
20+
container=${dialer[$rand]}
21+
docker rm -f "$container" >/dev/null &
22+
unset dialer[$rand]
23+
dialer=("${dialer[@]}")
24+
fi
2425

25-
sleep $(( rand % 3 ))
26+
sleep $((rand % 3))
2627
done

0 commit comments

Comments
 (0)