Remove some bashisms

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-02-26 12:09:21 +01:00
parent cdba45bd8b
commit 5aeb7a0f55
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
6 changed files with 20 additions and 23 deletions

View File

@ -21,7 +21,7 @@ jobs=(
# each container has access to two cores. # each container has access to two cores.
group=${CROSS_GROUP-"all"} group=${CROSS_GROUP-"all"}
if [ "$group" == "all" ]; then if [ "$group" = "all" ]; then
echo "Building binaries for all platforms" echo "Building binaries for all platforms"
parallel ::: "${jobs[@]}" parallel ::: "${jobs[@]}"

View File

@ -14,7 +14,7 @@ RESOURCES=$SCRIPTDIR/../winresources
TEMPDIR=$(mktemp -d) TEMPDIR=$(mktemp -d)
trap 'rm -rf $TEMPDIR' EXIT trap 'rm -rf $TEMPDIR' EXIT
if [ "$(go env GOHOSTOS)" == "windows" ]; then if [ "$(go env GOHOSTOS)" = "windows" ]; then
WINDRES=windres WINDRES=windres
else else
# Cross compiling # Cross compiling
@ -22,7 +22,7 @@ else
fi fi
# Generate a Windows file version of the form major,minor,patch,build (with any part optional) # Generate a Windows file version of the form major,minor,patch,build (with any part optional)
VERSION_QUAD=$(echo -n "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,) VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,)
# Pass version and commit information into the resource compiler # Pass version and commit information into the resource compiler
defs= defs=
@ -30,7 +30,7 @@ defs=
[ ! -z "$VERSION_QUAD" ] && defs+=( "-D DOCKER_VERSION_QUAD=$VERSION_QUAD") [ ! -z "$VERSION_QUAD" ] && defs+=( "-D DOCKER_VERSION_QUAD=$VERSION_QUAD")
[ ! -z "$GITCOMMIT" ] && defs+=( "-D DOCKER_COMMIT=\"$GITCOMMIT\"") [ ! -z "$GITCOMMIT" ] && defs+=( "-D DOCKER_COMMIT=\"$GITCOMMIT\"")
function makeres { makeres() {
"$WINDRES" \ "$WINDRES" \
-i "$RESOURCES/$1" \ -i "$RESOURCES/$1" \
-o "$3" \ -o "$3" \

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu -o pipefail set -eu -o pipefail
if [[ -n "${REMOTE_DAEMON-}" ]]; then if [ -n "${REMOTE_DAEMON-}" ]; then
# Run tests against a remote daemon. # Run tests against a remote daemon.
./scripts/test/e2e/run fetch-images ./scripts/test/e2e/run fetch-images
./scripts/test/e2e/run test "${DOCKER_HOST-}" ./scripts/test/e2e/run test "${DOCKER_HOST-}"

View File

@ -8,16 +8,13 @@ alpine_dest=registry:5000/alpine:3.6
busybox_src=busybox@sha256:3e8fa85ddfef1af9ca85a5cfb714148956984e02f00bec3f7f49d3925a91e0e7 busybox_src=busybox@sha256:3e8fa85ddfef1af9ca85a5cfb714148956984e02f00bec3f7f49d3925a91e0e7
busybox_dest=registry:5000/busybox:1.27.2 busybox_dest=registry:5000/busybox:1.27.2
function fetch_tag_image { fetch_tag_image() {
local src=$1 docker pull "$1"
local dest=$2 docker tag "$1" "$2"
docker pull "$src"
docker tag "$src" "$dest"
} }
function push_image { push_image() {
local img=$1 docker push "$1"
docker push "$img"
} }
cmd=${1-} cmd=${1-}

View File

@ -2,24 +2,24 @@
# Run integration tests against the latest docker-ce dind # Run integration tests against the latest docker-ce dind
set -eu -o pipefail set -eu -o pipefail
function container_ip { container_ip() {
local cid=$1 local cid=$1
local network=$2 local network=$2
docker inspect \ docker inspect \
-f "{{.NetworkSettings.Networks.${network}.IPAddress}}" "$cid" -f "{{.NetworkSettings.Networks.${network}.IPAddress}}" "$cid"
} }
function fetch_images { fetch_images() {
./scripts/test/e2e/load-image fetch-only ./scripts/test/e2e/load-image fetch-only
} }
function setup { setup() {
local project=$1 local project=$1
local file=$2 local file=$2
test "${DOCKERD_EXPERIMENTAL:-0}" -eq "1" && file="${file}:./e2e/compose-env.experimental.yaml" test "${DOCKERD_EXPERIMENTAL:-0}" -eq "1" && file="${file}:./e2e/compose-env.experimental.yaml"
if [[ "${TEST_CONNHELPER:-}" = "ssh" ]];then if [ "${TEST_CONNHELPER:-}" = "ssh" ];then
test ! -f "${HOME}/.ssh/id_rsa" && ssh-keygen -t rsa -C docker-e2e-dummy -N "" -f "${HOME}/.ssh/id_rsa" -q test ! -f "${HOME}/.ssh/id_rsa" && ssh-keygen -t rsa -C docker-e2e-dummy -N "" -f "${HOME}/.ssh/id_rsa" -q
grep "^StrictHostKeyChecking no" "${HOME}/.ssh/config" > /dev/null 2>&1 || echo "StrictHostKeyChecking no" > "${HOME}/.ssh/config" grep "^StrictHostKeyChecking no" "${HOME}/.ssh/config" > /dev/null 2>&1 || echo "StrictHostKeyChecking no" > "${HOME}/.ssh/config"
TEST_CONNHELPER_SSH_ID_RSA_PUB=$(cat "${HOME}/.ssh/id_rsa.pub") TEST_CONNHELPER_SSH_ID_RSA_PUB=$(cat "${HOME}/.ssh/id_rsa.pub")
@ -34,7 +34,7 @@ function setup {
engine_ip="$(container_ip "${project}_engine_1" "$network")" engine_ip="$(container_ip "${project}_engine_1" "$network")"
engine_host="tcp://$engine_ip:2375" engine_host="tcp://$engine_ip:2375"
if [[ "${TEST_CONNHELPER:-}" = "ssh" ]];then if [ "${TEST_CONNHELPER:-}" = "ssh" ];then
engine_host="ssh://penguin@${engine_ip}" engine_host="ssh://penguin@${engine_ip}"
fi fi
( (
@ -46,18 +46,18 @@ function setup {
echo "$engine_host" echo "$engine_host"
} }
function is_swarm_enabled { is_swarm_enabled() {
docker info 2> /dev/null | grep -q 'Swarm: active' docker info 2> /dev/null | grep -q 'Swarm: active'
} }
function cleanup { cleanup() {
local project=$1 local project=$1
local network="${project}_default" local network="${project}_default"
docker network disconnect "$network" "$(hostname)" docker network disconnect "$network" "$(hostname)"
COMPOSE_PROJECT_NAME=$1 COMPOSE_FILE=$2 docker-compose down -v --rmi local >&2 COMPOSE_PROJECT_NAME=$1 COMPOSE_FILE=$2 docker-compose down -v --rmi local >&2
} }
function runtests { runtests() {
local engine_host=$1 local engine_host=$1
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -93,7 +93,7 @@ case "$cmd" in
;; ;;
test) test)
engine_host=${2-} engine_host=${2-}
if [[ -z "${engine_host}" ]]; then if [ -z "${engine_host}" ]; then
echo "missing parameter docker engine host" echo "missing parameter docker engine host"
echo "Usage: $0 test ENGINE_HOST" echo "Usage: $0 test ENGINE_HOST"
exit 3 exit 3

View File

@ -6,7 +6,7 @@ engine_host=$(./scripts/test/e2e/run setup)
testexit=0 testexit=0
test_cmd="test" test_cmd="test"
if [[ -n "${TEST_DEBUG-}" ]]; then if [ -n "${TEST_DEBUG-}" ]; then
test_cmd="shell" test_cmd="shell"
fi fi