-
Notifications
You must be signed in to change notification settings - Fork 712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix linter errors #2068
Merged
Merged
Fix linter errors #2068
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d9ce1d5
Squashed 'tools/' changes from b990f488..4b7d5c61
iaguis 3522a3f
Merge commit 'd9ce1d58e9cbcd67823ee0abe8dd346a9aa6d120' into iaguis/f…
iaguis 5d06a23
tools: remove generate_latest_map
iaguis 643827d
Re-add generate_latest_map script
iaguis ec0b6dd
backend: add shfmt command to the docker image
iaguis 43d9f38
Fix various linter issues
iaguis 5cb5c7d
Fix shfmt issues
iaguis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,12 @@ DOCKERHUB_USER=${DOCKERHUB_USER:-weaveworks} | |
RELEASE_NAME=${RELEASE_NAME:-"Weave Scope"} | ||
RELEASE_DESCRIPTION=${RELEASE_DESCRIPTION:-"Container Visibility"} | ||
|
||
PWD=`pwd` | ||
WC="wc" | ||
# Use GNU wc on Darwin | ||
case $OSTYPE in darwin*) WC="gwc" ;; esac | ||
PWD=$(pwd) | ||
|
||
infer_release_type() { | ||
if echo $1 | grep -qE '^v[0-9]+\.[0-9]+\.0+$' ; then | ||
if echo "$1" | grep -qE '^v[0-9]+\.[0-9]+\.0+$'; then | ||
echo MAINLINE | ||
elif echo $1 | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$' ; then | ||
elif echo "$1" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then | ||
echo BRANCH | ||
else | ||
echo PRERELEASE | ||
|
@@ -26,10 +23,12 @@ infer_release_type() { | |
setup() { | ||
# Ensure we have exactly one annotated tag pointing at HEAD | ||
HEAD_TAGS=$(git tag --points-at HEAD) | ||
TAG_COUNT=$(echo $(echo $HEAD_TAGS | wc -w)) # mac hack | ||
# shellcheck disable=SC2116 | ||
# shellcheck disable=SC2005 | ||
TAG_COUNT=$(echo "$(echo "$HEAD_TAGS" | wc -w)") # mac hack | ||
case $TAG_COUNT in | ||
1) | ||
if [ $HEAD_TAGS != "latest_release" ] ; then | ||
if [ "$HEAD_TAGS" != "latest_release" ]; then | ||
LATEST_TAG=$HEAD_TAGS | ||
else | ||
echo "Cannot determine version - latest_release points at HEAD" >&2 | ||
|
@@ -42,21 +41,21 @@ setup() { | |
;; | ||
*) | ||
echo "Cannot determine version - multiple tags point at HEAD:" >&2 | ||
for TAG in $HEAD_TAGS ; do | ||
for TAG in $HEAD_TAGS; do | ||
echo -e "\t$TAG" >&2 | ||
done | ||
exit 1 | ||
;; | ||
esac | ||
|
||
RELEASE_TYPE=$(infer_release_type $LATEST_TAG) | ||
RELEASE_TYPE=$(infer_release_type "$LATEST_TAG") | ||
echo "== Inferred release type $RELEASE_TYPE from tag $LATEST_TAG" | ||
|
||
LATEST_TAG_SHA=$(git rev-parse $LATEST_TAG) | ||
LATEST_TAG_COMMIT_SHA=$(git rev-list -1 $LATEST_TAG) | ||
LATEST_TAG_SHA=$(git rev-parse "$LATEST_TAG") | ||
LATEST_TAG_COMMIT_SHA=$(git rev-list -1 "$LATEST_TAG") | ||
LATEST_RELEASE_SHA=$(git rev-parse latest_release) | ||
LATEST_RELEASE_COMMIT_SHA=$(git rev-list -1 latest_release) | ||
if [ "$RELEASE_TYPE" != 'PRERELEASE' ] ; then | ||
if [ "$RELEASE_TYPE" != 'PRERELEASE' ]; then | ||
VERSION=${LATEST_TAG#v} | ||
else | ||
VERSION=${LATEST_TAG} | ||
|
@@ -69,20 +68,20 @@ build() { | |
setup | ||
|
||
echo "== Clone repo at $LATEST_TAG for version $VERSION" | ||
if [ -d $RELEASE_DIR ]; then | ||
if [ -d "$RELEASE_DIR" ]; then | ||
echo -e "\u2757 Release directory $RELEASE_DIR already exists, you may want to" >&2 | ||
echo -e "\trm -rf $RELEASE_DIR" >&2 | ||
exit 1 | ||
fi | ||
|
||
## Clone the repo at the tag and go there | ||
mkdir -p releases | ||
git clone -q -b $LATEST_TAG . $RELEASE_DIR 2>/dev/null | ||
cd $RELEASE_DIR | ||
git clone -q -b "$LATEST_TAG" . "$RELEASE_DIR" 2>/dev/null | ||
cd "$RELEASE_DIR" | ||
|
||
## Check that the top changelog entry is this version | ||
if ! latest_changelog=$(perl -nle'print $& if m{(?<=^## Release ).*}' ./CHANGELOG.md | head -1) || \ | ||
! [ `echo "$latest_changelog" = "$VERSION"` ]; then | ||
if ! latest_changelog=$(perl -nle'print $& if m{(?<=^## Release ).*}' ./CHANGELOG.md | head -1) \ | ||
|| ! [ "$latest_changelog" = "$VERSION" ]; then | ||
echo -e "\u2757 Latest changelog entry \"$latest_changelog\" does not match the release version $VERSION" >&2 | ||
exit 1 | ||
fi | ||
|
@@ -93,9 +92,9 @@ build() { | |
## Inject the version numbers and build the distributables | ||
## (library versions?) | ||
sed -i.tmp "s/SCRIPT_VERSION=\"[^\"]*\"/SCRIPT_VERSION=\"$VERSION\"/" ./scope | ||
make SUDO=$SUDO SCOPE_VERSION=$VERSION DOCKERHUB_USER=$DOCKERHUB_USER | ||
make SUDO="$SUDO" SCOPE_VERSION="$VERSION" DOCKERHUB_USER="$DOCKERHUB_USER" | ||
|
||
if make tests SUDO=$SUDO; then | ||
if make tests SUDO="$SUDO"; then | ||
echo -e '\u2713 Tests pass' | ||
else | ||
echo -e "\u2757 Tests failed, probably best not publish this one" >&2 | ||
|
@@ -110,18 +109,18 @@ build() { | |
#fi | ||
|
||
echo -e '\u2713 Build OK' | ||
echo '** Release artefacts in' $RELEASE_DIR | ||
echo '** Release artefacts in' "$RELEASE_DIR" | ||
} | ||
|
||
draft() { | ||
setup | ||
|
||
cd $PWD/$RELEASE_DIR | ||
cd "$PWD"/"$RELEASE_DIR" | ||
|
||
echo "== Sanity checks" | ||
|
||
## Check that the tag exists by looking at github | ||
if ! curl -sSf https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_TAG_SHA >/dev/null 2>&1; then | ||
if ! curl -sSf "https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_TAG_SHA" >/dev/null 2>&1; then | ||
echo -e "\u2757 Tag $LATEST_TAG is not on GitHub, or is not the same as the local tag" >&2 | ||
echo -e "\thttps://github.com/$GITHUB_USER/scope/tags" >&2 | ||
echo "You may need to" >&2 | ||
|
@@ -133,31 +132,31 @@ draft() { | |
|
||
## Check that the version does not already exist by looking at github | ||
## releases | ||
if github-release info --user $GITHUB_USER --repo scope --tag $LATEST_TAG >/dev/null 2>&1; then | ||
if github-release info --user "$GITHUB_USER" --repo scope --tag "$LATEST_TAG" >/dev/null 2>&1; then | ||
echo -e "\u2757 Release $LATEST_TAG already exists on GitHub" >&2 | ||
echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" >&2 | ||
exit 1 | ||
fi | ||
|
||
echo '** Sanity checks OK for publishing tag' $LATEST_TAG as $DOCKERHUB_USER/scope:$VERSION | ||
echo '** Sanity checks OK for publishing tag' "$LATEST_TAG" as "$DOCKERHUB_USER/scope:$VERSION" | ||
|
||
RELEASE_ARGS="--draft" | ||
if [ "$RELEASE_TYPE" = 'PRERELEASE' ] ; then | ||
if [ "$RELEASE_TYPE" = 'PRERELEASE' ]; then | ||
RELEASE_ARGS="$RELEASE_ARGS --pre-release" | ||
fi | ||
|
||
echo "== Creating GitHub release $RELEASE_ARGS $RELEASE_NAME $VERSION" | ||
github-release release $RELEASE_ARGS \ | ||
--user $GITHUB_USER \ | ||
github-release release "$RELEASE_ARGS" \ | ||
--user "$GITHUB_USER" \ | ||
--repo scope \ | ||
--tag $LATEST_TAG \ | ||
--tag "$LATEST_TAG" \ | ||
--name "$RELEASE_NAME $VERSION" \ | ||
--description "$RELEASE_DESCRIPTION" | ||
|
||
github-release upload \ | ||
--user $GITHUB_USER \ | ||
--user "$GITHUB_USER" \ | ||
--repo scope \ | ||
--tag $LATEST_TAG \ | ||
--tag "$LATEST_TAG" \ | ||
--name "scope" \ | ||
--file "./scope" | ||
|
||
|
@@ -167,76 +166,71 @@ draft() { | |
|
||
publish() { | ||
setup | ||
cd $PWD/$RELEASE_DIR | ||
cd "$PWD"/"$RELEASE_DIR" | ||
|
||
UPDATE_LATEST=false | ||
if [ "$RELEASE_TYPE" = 'MAINLINE' ] ; then | ||
UPDATE_LATEST=true | ||
fi | ||
|
||
if [ "$RELEASE_TYPE" = 'PRERELEASE' ] ; then | ||
if [ "$RELEASE_TYPE" = 'PRERELEASE' ]; then | ||
echo "== Tagging and pushing images on docker hub as user $DOCKERHUB_USER" | ||
$SUDO docker tag -f $DOCKERHUB_USER/scope $DOCKERHUB_USER/scope:$VERSION | ||
$SUDO docker push $DOCKERHUB_USER/scope:$VERSION | ||
$SUDO docker tag -f "$DOCKERHUB_USER"/scope "$DOCKERHUB_USER/scope:$VERSION" | ||
$SUDO docker push "$DOCKERHUB_USER/scope:$VERSION" | ||
echo "** Docker images tagged and pushed" | ||
|
||
echo "== Publishing pre-release on GitHub" | ||
|
||
github-release publish \ | ||
--user $GITHUB_USER \ | ||
--user "$GITHUB_USER" \ | ||
--repo scope \ | ||
--tag $LATEST_TAG | ||
--tag "$LATEST_TAG" | ||
|
||
echo "** Pre-release $RELEASE_NAME $VERSION published at" | ||
echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" | ||
else | ||
echo "== Sanity checks" | ||
if ! [ "$LATEST_TAG_COMMIT_SHA" == "$LATEST_RELEASE_COMMIT_SHA" ] ; then | ||
if ! [ "$LATEST_TAG_COMMIT_SHA" == "$LATEST_RELEASE_COMMIT_SHA" ]; then | ||
echo -e "\u2757 The tag latest_release does not point to the same commit as $LATEST_TAG" >&2 | ||
echo "You may need to" >&2 | ||
echo -e "\tgit tag -af latest_release $LATEST_TAG" >&2 | ||
exit 1 | ||
fi | ||
|
||
## Check that the 'latest_release' tag exists by looking at github | ||
if ! curl -sSf https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_RELEASE_SHA >/dev/null 2>&1; then | ||
if ! curl -sSf "https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_RELEASE_SHA" >/dev/null 2>&1; then | ||
echo -e "\u2757 Tag latest_release is not on GitHub, or is not the same as the local tag" >&2 | ||
echo -e "\thttps://github.com/$GITHUB_USER/scope/tags" >&2 | ||
echo "You may need to" >&2 | ||
echo -e "\tgit push -f [email protected]:$GITHUB_USER/scope latest_release" >&2 | ||
exit 1 | ||
fi | ||
echo '** Sanity checks OK for publishing tag' $LATEST_TAG as $DOCKERHUB_USER/scope:$VERSION | ||
echo '** Sanity checks OK for publishing tag' "$LATEST_TAG" as "$DOCKERHUB_USER/scope:$VERSION" | ||
|
||
echo "== Tagging and pushing images on docker hub as user $DOCKERHUB_USER" | ||
$SUDO docker tag -f $DOCKERHUB_USER/scope $DOCKERHUB_USER/scope:$VERSION | ||
$SUDO docker push $DOCKERHUB_USER/scope:$VERSION | ||
$SUDO docker tag -f "$DOCKERHUB_USER"/scope "$DOCKERHUB_USER/scope:$VERSION" | ||
$SUDO docker push "$DOCKERHUB_USER"/scope:$"VERSION" | ||
echo "** Docker images tagged and pushed" | ||
|
||
echo "== Publishing release on GitHub" | ||
|
||
github-release publish \ | ||
--user $GITHUB_USER \ | ||
--user "$GITHUB_USER" \ | ||
--repo scope \ | ||
--tag $LATEST_TAG | ||
--tag "$LATEST_TAG" | ||
|
||
if github-release info --user $GITHUB_USER --repo scope \ | ||
if github-release info --user "$GITHUB_USER" --repo scope \ | ||
--tag latest_release >/dev/null 2>&1; then | ||
github-release delete \ | ||
--user $GITHUB_USER \ | ||
--user "$GITHUB_USER" \ | ||
--repo scope \ | ||
--tag latest_release | ||
fi | ||
|
||
github-release release \ | ||
--user $GITHUB_USER \ | ||
--user "$GITHUB_USER" \ | ||
--repo scope \ | ||
--tag latest_release \ | ||
--name "$RELEASE_NAME latest ($VERSION)" \ | ||
--description "[Release Notes](https://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG)" | ||
|
||
github-release upload \ | ||
--user $GITHUB_USER \ | ||
--user "$GITHUB_USER" \ | ||
--repo scope \ | ||
--tag latest_release \ | ||
--name "scope" \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck disable=SC1091 | ||
source /var/run/weave/scope-app.args | ||
|
||
exec -a scope-app /home/weave/scope --mode app "${ARGS[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck disable=SC1091 | ||
source /var/run/weave/scope-probe.args | ||
|
||
exec -a scope-probe /home/weave/scope --mode probe "${ARGS[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
#!/bin/bash | ||
set -eu | ||
if [ $# -lt 1 ]; then | ||
echo "Usage: $0 <ip:port> [<max_dialer>]" >&2 | ||
exit 1 | ||
echo "Usage: $0 <ip:port> [<max_dialer>]" >&2 | ||
exit 1 | ||
fi | ||
|
||
readonly addr=$1 | ||
readonly max_dialer=${2:-50} | ||
|
||
dialer=() | ||
# shellcheck disable=SC2154 | ||
trap 'echo -n "stopping ... "; for c in "${dialer[@]}"; do docker rm -f "$c" >/dev/null; done; echo "done"' EXIT | ||
|
||
while true; do | ||
rand=$(( ( RANDOM % max_dialer ) + 1 )) | ||
dialer+=("$(docker run -d dialer /go/bin/dialer connect "$addr" "$rand")") | ||
rand=$(((RANDOM % max_dialer) + 1)) | ||
dialer+=("$(docker run -d dialer /go/bin/dialer connect "$addr" "$rand")") | ||
|
||
if [ ${#dialer[@]} -gt "$max_dialer" ]; then | ||
container=${dialer[$rand]} | ||
docker rm -f "$container" >/dev/null & | ||
unset dialer[$rand] | ||
dialer=("${dialer[@]}") | ||
fi | ||
if [ ${#dialer[@]} -gt "$max_dialer" ]; then | ||
container=${dialer[$rand]} | ||
docker rm -f "$container" >/dev/null & | ||
unset dialer[$rand] | ||
dialer=("${dialer[@]}") | ||
fi | ||
|
||
sleep $(( rand % 3 )) | ||
sleep $((rand % 3)) | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as abuse.
Sorry, something went wrong.