fix: migrate env files before reading deprecated vars
Install steps run in alphabetical order of the enabled plugin directory, so `apps`, `builder`, and `checks` read an app's environment before the `config` plugin had moved the `ENV` file to its new location. The read came back empty, so their deprecated `DOKKU_*` variables were never migrated to the matching plugin property and were never unset, with nothing reported either way: `dokku config:show` kept listing the variable while the plugin behaved as though it were unset. The relocation now runs before any deprecated variable is read, whatever the install order, and each old file is removed as soon as it has been drained rather than on a later install, which also covers the global file that was never removed at all. A file that reappears at the old path can only have been written by hand, so it is merged in with a warning naming its keys instead of being discarded.
This commit is contained in:
@@ -586,3 +586,69 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_output '[{"name":"BKEY","value":"true"},{"name":"aKey","value":"true"},{"name":"bKey","value":"true"},{"name":"zKey","value":"true"}]'
|
||||
}
|
||||
|
||||
@test "(config) install migrates a pre-0.38 ENV file before plugins read it" {
|
||||
# The checks plugin installs before the config plugin, so before this was
|
||||
# fixed it read the not-yet-relocated ENV file, found nothing, and migrated
|
||||
# DOKKU_CHECKS_SKIPPED to the checks property silently doing nothing.
|
||||
run /bin/bash -c "sudo rm -f ${DOKKU_LIB_ROOT}/config/config/$TEST_APP/env-migrated ${DOKKU_LIB_ROOT}/config/checks/$TEST_APP/skipped"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "echo 'export DOKKU_CHECKS_SKIPPED=worker' | sudo tee $DOKKU_ROOT/$TEST_APP/ENV && sudo chown dokku:dokku $DOKKU_ROOT/$TEST_APP/ENV"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku plugin:install --core"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku checks:report $TEST_APP --checks-skipped-list"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "worker"
|
||||
|
||||
run /bin/bash -c "dokku config:show $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "DOKKU_CHECKS_SKIPPED" 0
|
||||
|
||||
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/ENV"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "(config) config-migrate-env imports an ENV file written after migration" {
|
||||
# record the migration as already done, so the ENV file below can only have
|
||||
# been written by hand rather than by an upgrade
|
||||
run /bin/bash -c "sudo mkdir -p ${DOKKU_LIB_ROOT}/config/config/$TEST_APP && printf true | sudo tee ${DOKKU_LIB_ROOT}/config/config/$TEST_APP/env-migrated"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "echo 'export HAND_EDITED=yes' | sudo tee $DOKKU_ROOT/$TEST_APP/ENV && sudo chown dokku:dokku $DOKKU_ROOT/$TEST_APP/ENV"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run_plugn_trigger config-migrate-env
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "$DOKKU_ROOT/$TEST_APP/ENV"
|
||||
|
||||
run /bin/bash -c "dokku config:get $TEST_APP HAND_EDITED"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "yes"
|
||||
|
||||
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/ENV"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user