Merge pull request #3137 from dokku/fix-empty-rev-env-var
fix: ensure we can disable setting the rev-env-var
This commit is contained in:
5 files changed
+29
-13
No files matched your search
@@ -27,6 +27,20 @@ fn-plugin-property-destroy() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn-plugin-property-exists() {
|
||||||
|
declare desc="returns whether the property store has a value for an app"
|
||||||
|
declare PLUGIN="$1" APP="$2" KEY="$3" DEFAULT="$4"
|
||||||
|
local CONFIG_VALUE
|
||||||
|
|
||||||
|
if [[ -z "$PLUGIN" ]] || [[ -z "$APP" ]] || [[ -z "$KEY" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "${DOKKU_LIB_ROOT:?}/config/${PLUGIN}/${APP}/${KEY}" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
fn-plugin-property-get() {
|
fn-plugin-property-get() {
|
||||||
declare desc="returns the property store value for an app"
|
declare desc="returns the property store value for an app"
|
||||||
declare PLUGIN="$1" APP="$2" KEY="$3" DEFAULT="$4"
|
declare PLUGIN="$1" APP="$2" KEY="$3" DEFAULT="$4"
|
||||||
|
|||||||
@@ -152,14 +152,18 @@ git_hook_cmd() {
|
|||||||
|
|
||||||
git_build() {
|
git_build() {
|
||||||
declare desc="setup and call git_build_app_repo"
|
declare desc="setup and call git_build_app_repo"
|
||||||
local APP="$1"
|
local APP="$1" REV="$2"
|
||||||
local DOKKU_DEPLOY_BRANCH ENV_VAR_NAME REF
|
local DOKKU_DEPLOY_BRANCH ENV_VAR_NAME REF
|
||||||
if [[ $# -ge 2 ]]; then
|
if [[ $# -ge 2 ]]; then
|
||||||
ENV_VAR_NAME="$(fn-plugin-property-get "git" "$APP" "rev-env-var" "GIT_REV")"
|
ENV_VAR_NAME="$(fn-plugin-property-get "git" "$APP" "rev-env-var")"
|
||||||
|
if [[ -z "$ENV_VAR_NAME" ]] && ! fn-plugin-property-exists "git" "$APP" "rev-env-var"; then
|
||||||
|
ENV_VAR_NAME="GIT_REV"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n "$ENV_VAR_NAME" ]]; then
|
if [[ -n "$ENV_VAR_NAME" ]]; then
|
||||||
config_set --no-restart "$APP" "${ENV_VAR_NAME}=${REV}" > /dev/null
|
config_set --no-restart "$APP" "${ENV_VAR_NAME}=${REV}" > /dev/null
|
||||||
fi
|
fi
|
||||||
local REF="$2"
|
local REF="$REV"
|
||||||
else
|
else
|
||||||
DOKKU_DEPLOY_BRANCH="$(git_deploy_branch "$APP")"
|
DOKKU_DEPLOY_BRANCH="$(git_deploy_branch "$APP")"
|
||||||
REF=$(< "$DOKKU_ROOT/$APP/refs/heads/$DOKKU_DEPLOY_BRANCH")
|
REF=$(< "$DOKKU_ROOT/$APP/refs/heads/$DOKKU_DEPLOY_BRANCH")
|
||||||
|
|||||||
@@ -30,9 +30,13 @@ git-set-cmd() {
|
|||||||
fn-plugin-property-write "git" "$APP" "$KEY" "$VALUE"
|
fn-plugin-property-write "git" "$APP" "$KEY" "$VALUE"
|
||||||
else
|
else
|
||||||
dokku_log_info2_quiet "Unsetting ${KEY}"
|
dokku_log_info2_quiet "Unsetting ${KEY}"
|
||||||
fn-plugin-property-delete "git" "$APP" "$KEY"
|
if [[ "$KEY" == "rev-env-var" ]]; then
|
||||||
if [[ "$KEY" == "enabled" ]]; then
|
fn-plugin-property-write "git" "$APP" "$KEY" "$VALUE"
|
||||||
fn-plugin-property-destroy "git" "$APP"
|
else
|
||||||
|
fn-plugin-property-delete "git" "$APP" "$KEY"
|
||||||
|
if [[ "$KEY" == "enabled" ]]; then
|
||||||
|
fn-plugin-property-destroy "git" "$APP"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ teardown() {
|
|||||||
run bash -c "dokku config:get $TEST_APP GIT_REV"
|
run bash -c "dokku config:get $TEST_APP GIT_REV"
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_output_empty
|
assert_output ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(git) customize the GIT_REV environment variable" {
|
@test "(git) customize the GIT_REV environment variable" {
|
||||||
|
|||||||
@@ -77,12 +77,6 @@ assert_output_exists() {
|
|||||||
[[ -n "$output" ]] || flunk "expected output, found none"
|
[[ -n "$output" ]] || flunk "expected output, found none"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ShellCheck doesn't know about $output from Bats
|
|
||||||
# shellcheck disable=SC2154
|
|
||||||
assert_output_empty() {
|
|
||||||
[[ -z "$output" ]] || flunk "expected no output, found $output"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ShellCheck doesn't know about $output from Bats
|
# ShellCheck doesn't know about $output from Bats
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
assert_output_contains() {
|
assert_output_contains() {
|
||||||
|
|||||||
Reference in new issue
Block a user