Skip to content

Commit

Permalink
Fix shfmt issues
Browse files Browse the repository at this point in the history
  • Loading branch information
iaguis committed Jan 18, 2017
1 parent 43d9f38 commit 5cb5c7d
Show file tree
Hide file tree
Showing 23 changed files with 223 additions and 227 deletions.
24 changes: 12 additions & 12 deletions bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ RELEASE_DESCRIPTION=${RELEASE_DESCRIPTION:-"Container Visibility"}
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
Expand All @@ -28,7 +28,7 @@ setup() {
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
Expand All @@ -41,7 +41,7 @@ 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
Expand All @@ -55,7 +55,7 @@ setup() {
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}
Expand All @@ -80,8 +80,8 @@ build() {
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) || \
! [ "$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
Expand Down Expand Up @@ -141,7 +141,7 @@ draft() {
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

Expand All @@ -168,10 +168,10 @@ publish() {
setup
cd "$PWD"/"$RELEASE_DIR"

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 push "$DOCKERHUB_USER/scope:$VERSION"
echo "** Docker images tagged and pushed"

echo "== Publishing pre-release on GitHub"
Expand All @@ -185,7 +185,7 @@ publish() {
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
Expand All @@ -204,7 +204,7 @@ publish() {

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 push "$DOCKERHUB_USER"/scope:$"VERSION"
echo "** Docker images tagged and pushed"

echo "== Publishing release on GitHub"
Expand Down
5 changes: 2 additions & 3 deletions bin/setup-circleci-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ set -eu
# openssl enc -in do-setup-circleci-secrets.orig -out setup-circleci-secrets.orig -e -aes256 -pass stdin
# openssl base64 < setup-circleci-secrets.orig

openssl base64 -d << EOF \
| openssl enc \
openssl base64 -d <<EOF | openssl enc \
-out bin/do-setup-circleci-secrets \
-d -aes256 -pass pass:"$1"
-d -aes256 -pass pass:"$1"
U2FsdGVkX193YHZJXNzxU9GqigQaXWrA0AKd+BIjRcx7bmmKn/zSgOv+FfApRRjn
KGBd2ulZw9CwsftX0HWHzVdtpgqbJUW+FEma8eNldau4/f+T+yWTVpCNQXGc3DvB
cWYhmkoTfGWmI2v/0/Bv2TYkw7MAfjCocdluFAv7sSvYnSgIjoYxD4XXkTjLWy1P
Expand Down
8 changes: 4 additions & 4 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ mkdir -p /var/run/weave

for arg in "$@"; do
case "$arg" in
--no-app|--probe-only|--service-token*|--probe.token*)
--no-app | --probe-only | --service-token* | --probe.token*)
touch /etc/service/app/down
;;
--no-probe|--app-only)
--no-probe | --app-only)
touch /etc/service/probe/down
;;
esac
Expand All @@ -16,8 +16,8 @@ done
# shellcheck disable=SC2034
ARGS=("$@")

typeset -p ARGS >/var/run/weave/scope-app.args
declare -p ARGS >/var/run/weave/scope-app.args
# shellcheck disable=SC2034
typeset -p ARGS >/var/run/weave/scope-probe.args
declare -p ARGS >/var/run/weave/scope-probe.args

exec /home/weave/runsvinit
2 changes: 1 addition & 1 deletion docker/run-app
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# shellcheck disable=SC1091
source /var/run/weave/scope-app.args

exec -a scope-app /home/weave/scope --mode app "${ARGS[@]}"
22 changes: 11 additions & 11 deletions extras/dialer/dialer
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/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
Expand All @@ -13,15 +13,15 @@ dialer=()
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
4 changes: 2 additions & 2 deletions extras/dialer/listener
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -eu
readonly port=${1:-8082}
(
sleep 5 # wait for dialerserver to start
echo "IP addr + port: $(docker inspect -f '{{ .NetworkSettings.IPAddress }}' dialerserver):$port"
sleep 5 # wait for dialerserver to start
echo "IP addr + port: $(docker inspect -f '{{ .NetworkSettings.IPAddress }}' dialerserver):$port"
) &
docker run --rm --name dialerserver dialer /go/bin/dialer listen "$port"
26 changes: 13 additions & 13 deletions extras/dialer/time-scope-probe
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
set -eu
if [ $EUID -ne 0 ]; then
echo "You must be root!" >&2
exit 1
echo "You must be root!" >&2
exit 1
fi

readonly interval_num=${1:-60}
Expand All @@ -16,18 +16,18 @@ TIME_K2=0
TIME_T2=0

if [ "$(pidof scope-probe)" == "" ]; then
echo "No scope-probe process running - aborting" >&2
exit 1
echo "No scope-probe process running - aborting" >&2
exit 1
fi

for ((i=0; i<"$interval_num"; i++)); do
sleep "$interval_sleep"
TIME_U1=$TIME_U2
TIME_K1=$TIME_K2
TIME_T1=$TIME_T2
for ((i = 0; i < "$interval_num"; i++)); do
sleep "$interval_sleep"
TIME_U1=$TIME_U2
TIME_K1=$TIME_K2
TIME_T1=$TIME_T2

TIME_U2=$(gawk '{print $14"*10"}'<"/proc/$(pidof scope-probe)/stat" | bc)
TIME_K2=$(gawk '{print $15"*10"}'<"/proc/$(pidof scope-probe)/stat" | bc)
TIME_T2=$(( TIME_U2 + TIME_K2 ))
echo "utime $(( TIME_U2 - TIME_U1)) + stime $(( TIME_K2 - TIME_K1 )) = $(( TIME_T2 - TIME_T1 ))"
TIME_U2=$(gawk '{print $14"*10"}' <"/proc/$(pidof scope-probe)/stat" | bc)
TIME_K2=$(gawk '{print $15"*10"}' <"/proc/$(pidof scope-probe)/stat" | bc)
TIME_T2=$((TIME_U2 + TIME_K2))
echo "utime $((TIME_U2 - TIME_U1)) + stime $((TIME_K2 - TIME_K1)) = $((TIME_T2 - TIME_T1))"
done
1 change: 0 additions & 1 deletion extras/example/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ start_container 1 tomwilkie/echo echo
start_container 2 tomwilkie/app app
start_container 2 tomwilkie/frontend frontend --add-host=dns.weave.local:"$(weave docker-bridge-ip)"
start_container 1 tomwilkie/client client

13 changes: 6 additions & 7 deletions extras/example/run_tracer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ start_container() {
while [ "$#" -gt 0 ]; do
case "$1" in
--)
shift
break
;;
shift
break
;;
*)
docker_args="${docker_args} $1"
shift
;;
docker_args="${docker_args} $1"
shift
;;
esac
done
local container_args="$*"
Expand All @@ -46,4 +46,3 @@ start_container 1 tomwilkie/echo echo
start_container 1 tomwilkie/trace_app app
start_container 1 tomwilkie/client client -- -target app.weave.local \
-concurrency 1 -persist False

8 changes: 4 additions & 4 deletions extras/generate_latest_map
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# Depends on:
# - gofmt

function generate_header {
function generate_header() {
local out_file="${1}"
local cmd="${2}"

cat << EOF >"${out_file}"
cat <<EOF >"${out_file}"
// Generated file, do not edit.
// To regenerate, run ${cmd}
Expand All @@ -26,7 +26,7 @@ function generate_header {
EOF
}

function generate_latest_map {
function generate_latest_map() {
local out_file="$1"
local data_type="$2"
local uppercase_data_type="${data_type^}"
Expand All @@ -43,7 +43,7 @@ function generate_latest_map {
# shellcheck disable=SC2016
local json_value='`json:"value"`'

cat << EOF >>"${out_file}"
cat <<EOF >>"${out_file}"
type ${wire_entry_type} struct {
Timestamp time.Time ${json_timestamp}
Value ${data_type} ${json_value}
Expand Down
2 changes: 1 addition & 1 deletion extras/in_parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ echo Doing "$INPUTS"
for INPUT in $INPUTS; do
START=$(date +%s)
"$COMMAND" "$INPUT"
RUNTIME=$(( $(date +%s) - START ))
RUNTIME=$(($(date +%s) - START))

"../tools/sched" time "$INPUT" "$RUNTIME"
done
2 changes: 1 addition & 1 deletion integration/100_launch_test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /bin/bash

# shellcheck disable=SC1091
./config.sh
./config.sh

start_suite "Launch scope and check it boots"

Expand Down
2 changes: 1 addition & 1 deletion integration/110_shutdown_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ scope_on "$HOST1" stop
sleep 5

# Save stdout for debugging output
exec 3>&1
exec 3>&1
assert_raises "docker_on $HOST1 logs weavescope 2>&1 | grep 'app exiting' || (docker_on $HOST1 logs weavescope 2>&3 ; false)"
assert_raises "docker_on $HOST1 logs weavescope 2>&1 | grep 'probe exiting' || (docker_on $HOST1 logs weavescope 2>&3 ; false)"
assert_raises "docker_on $HOST1 inspect --format='{{.State.Running}}' weavescope" "false"
Expand Down
38 changes: 19 additions & 19 deletions integration/115_topologies_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ scope_on "$HOST1" launch
wait_for_containers "$HOST1" 60 weavescope

topology_is_not_empty() {
local host="$1"
local topology="$2"
local timeout="${5:-60}"

for _ in $(seq "$timeout"); do
local report
local count
report="$(curl -s "http://$host:4040/api/report")"
count=$(echo "$report" | jq -r ".$topology.nodes | length > 0" 2>/dev/null)

if [ "$count" = "true" ]; then
assert "curl -s http://$host:4040/api/report | jq -r '.$topology.nodes | length > 0'" true
return
fi
sleep 1
done

echo "Failed to find any nodes in the $topology topology after $timeout secs"
assert "curl -s http://$host:4040/api/report | jq -r '.$topology.nodes | length > 0'" true
local host="$1"
local topology="$2"
local timeout="${5:-60}"

for _ in $(seq "$timeout"); do
local report
local count
report="$(curl -s "http://$host:4040/api/report")"
count=$(echo "$report" | jq -r ".$topology.nodes | length > 0" 2>/dev/null)

if [ "$count" = "true" ]; then
assert "curl -s http://$host:4040/api/report | jq -r '.$topology.nodes | length > 0'" true
return
fi
sleep 1
done

echo "Failed to find any nodes in the $topology topology after $timeout secs"
assert "curl -s http://$host:4040/api/report | jq -r '.$topology.nodes | length > 0'" true
}

topology_is_not_empty "$HOST1" Endpoint
Expand Down
10 changes: 5 additions & 5 deletions integration/200_clustering_2_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ docker_on "$HOST2" run -dit --name db2 peterbourgon/tns-db
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports

check() {
has_container "$1" weave 2
has_container "$1" weaveproxy 2
has_container "$1" weavescope 2
has_container "$1" db1
has_container "$1" db2
has_container "$1" weave 2
has_container "$1" weaveproxy 2
has_container "$1" weavescope 2
has_container "$1" db1
has_container "$1" db2
}

check "$HOST1"
Expand Down
10 changes: 5 additions & 5 deletions integration/205_clustering_sans_weave_2_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ docker_on "$HOST2" run -dit --name db2 peterbourgon/tns-db
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports.

check() {
has_container "$1" weave 0
has_container "$1" weaveproxy 0
has_container "$1" weavescope 2
has_container "$1" db1
has_container "$1" db2
has_container "$1" weave 0
has_container "$1" weaveproxy 0
has_container "$1" weavescope 2
has_container "$1" db1
has_container "$1" db2
}

check "$HOST1"
Expand Down
Loading

0 comments on commit 5cb5c7d

Please sign in to comment.