lintball in build-env

This commit is contained in:
Michael Hobbs
2014-12-15 09:54:06 -08:00
parent 58d0bc983a
commit f9b7d5378d
3 changed files with 10 additions and 9 deletions

2
dokku
View File

@@ -176,7 +176,7 @@ EOF
done
if [ "$implemented" -eq 0 ]; then
echo " ! \`$@\` is not a dokku command."
echo " ! \`$*\` is not a dokku command."
echo " ! See \`dokku help\` for a list of available commands."
exit 1
fi

View File

@@ -5,8 +5,8 @@ APP="$1"; IMAGE="dokku/$APP"; BUILD_ENV=""
[[ -f "$DOKKU_ROOT/BUILD_ENV" ]] && cat "$DOKKU_ROOT/BUILD_ENV" >> "$DOKKU_ROOT/ENV" && rm "$DOKKU_ROOT/BUILD_ENV"
[[ ! $(grep CURL_CONNECT_TIMEOUT "$DOKKU_ROOT/ENV") ]] && echo "export CURL_CONNECT_TIMEOUT=5" >> "$DOKKU_ROOT/ENV"
[[ ! $(grep CURL_TIMEOUT "$DOKKU_ROOT/ENV") ]] && echo "export CURL_TIMEOUT=30" >> "$DOKKU_ROOT/ENV"
! (grep -q CURL_CONNECT_TIMEOUT "$DOKKU_ROOT/ENV") && echo "export CURL_CONNECT_TIMEOUT=5" >> "$DOKKU_ROOT/ENV"
! (grep -q CURL_TIMEOUT "$DOKKU_ROOT/ENV") && echo "export CURL_TIMEOUT=30" >> "$DOKKU_ROOT/ENV"
if [[ -f "$DOKKU_ROOT/ENV" ]]; then
BUILD_ENV+=$(< "$DOKKU_ROOT/ENV")
@@ -20,12 +20,12 @@ if [[ ! -z "$BUILD_ENV" ]]; then
echo "-----> Adding BUILD_ENV to build environment..."
# create build env files for use in buildpacks like this:
# https://github.com/niteoweb/heroku-buildpack-buildout/blob/5879fa3418f7d8e079f1aa5816ba1adde73f4948/bin/compile#L34
id=$(echo $BUILD_ENV |sed 's@export @@g'| docker run -i -a stdin $IMAGE /bin/bash -c "for ENV_VAR in `cat`; do echo \$ENV_VAR |sed 's@^\([^=]*\)=\(.*\)\$@echo \2 >/tmp/env/\1@g' >>/tmp/set_env.sh; done && mkdir -p /tmp/env && /bin/bash /tmp/set_env.sh")
test $(docker wait $id) -eq 0
id=$(echo $BUILD_ENV |sed 's@export @@g'| docker run -i -a stdin $IMAGE /bin/bash -c "for ENV_VAR in $(cat); do echo \$ENV_VAR |sed 's@^\([^=]*\)=\(.*\)\$@echo \2 >/tmp/env/\1@g' >>/tmp/set_env.sh; done && mkdir -p /tmp/env && /bin/bash /tmp/set_env.sh")
test "$(docker wait $id)" -eq 0
docker commit $id $IMAGE > /dev/null
# create build env for 'old style' buildpacks and dokku plugins
id=$(echo "$BUILD_ENV" | docker run -i -a stdin $IMAGE /bin/bash -c "cat >> /app/.env")
test $(docker wait $id) -eq 0
test "$(docker wait $id)" -eq 0
docker commit $id $IMAGE > /dev/null
fi

View File

@@ -1,10 +1,11 @@
#!/usr/bin/env bash
# constants
TEST_APP=my-cool-guy-test-app
# test functions
flunk() {
{ if [ "$#" -eq 0 ]; then cat -
else echo "$@"
else echo "$*"
fi
}
return 1
@@ -71,8 +72,8 @@ refute_line() {
}
assert() {
if ! "$@"; then
flunk "failed: $@"
if ! "$*"; then
flunk "failed: $*"
fi
}