From d020999e82d5c7b57256d0be34b5f1f96d241396 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Tue, 2 Jun 2015 17:52:39 +0100 Subject: [PATCH] cosmetic: more sensible function order --- weave | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/weave b/weave index 728e06f0..cba23a72 100755 --- a/weave +++ b/weave @@ -495,13 +495,24 @@ stop() { docker rm -f $1 >/dev/null 2>&1 || true } -http_call_ip() { - ip="$1" - port="$2" - http_verb="$3" - url="$4" - shift 4 - curl --connect-timeout 3 -s -X $http_verb "$@" http://$ip:$port$url +# Given a container name or short ID in $1, ensure the specified +# container is running and then print its full ID to stdout. If +# it's not running or doesn't exist, print an error to stderr and +# return with an indicative non-zero exit code. +container_id() { + if ! status=$(docker inspect --format='{{.State.Running}} {{.Id}}' $1 2>/dev/null) ; then + echo "Error: No such container: $1" >&2 + return 1 + fi + case "$status" in + true*) + echo "${status#true }" + ;; + *) + echo "$1 container is not running." >&2 + return 2 + ;; + esac } container_ip() { @@ -524,24 +535,13 @@ container_ip() { esac } -# Given a container name or short ID in $1, ensure the specified -# container is running and then print its full ID to stdout. If -# it's not running or doesn't exist, print an error to stderr and -# return with an indicative non-zero exit code. -container_id() { - if ! status=$(docker inspect --format='{{.State.Running}} {{.Id}}' $1 2>/dev/null) ; then - echo "Error: No such container: $1" >&2 - return 1 - fi - case "$status" in - true*) - echo "${status#true }" - ;; - *) - echo "$1 container is not running." >&2 - return 2 - ;; - esac +http_call_ip() { + ip="$1" + port="$2" + http_verb="$3" + url="$4" + shift 4 + curl --connect-timeout 3 -s -X $http_verb "$@" http://$ip:$port$url } # Call url $4 with http verb $3 on container $1 at port $2