feat: add json output to config:export

This change adds json output as both key/value as well as a list of objects. The former can be used in quick scripting environments, while the latter allows higher-level languages to have a bit more structure around how environment variables are declared. Specifically, systems such as kubernetes understand the latter method, while the former can be used within Nomad job files.
This commit is contained in:
Jose Diaz-Gonzalez
2019-04-21 17:00:04 -04:00
parent 4b63c96434
commit 04c9fe974e
4 changed files with 72 additions and 6 deletions

View File

@@ -155,6 +155,32 @@ teardown() {
run /bin/bash -c "dokku --app $TEST_APP config:show"
echo "output: $output"
echo "status: "$stat
assert_output "=====> $TEST_APP env vars"$'\nBKEY: true\naKey: true\nbKey: true\nzKey: true'
}
@test "(config) config:export" {
run /bin/bash -c "dokku --app $TEST_APP config:set zKey=true bKey=true BKEY=true aKey=true"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku config:export --format docker-args $TEST_APP"
echo "output: $output"
echo "status: "$stat
assert_output "--env=BKEY='true' --env=aKey='true' --env=bKey='true' --env=zKey='true'"
run /bin/bash -c "dokku config:export --format shell $TEST_APP"
echo "output: $output"
echo "status: "$stat
assert_output "BKEY='true' aKey='true' bKey='true' zKey='true' "
run /bin/bash -c "dokku config:export --format json $TEST_APP"
echo "output: $output"
echo "status: "$stat
assert_output '{"BKEY":"true","aKey":"true","bKey":"true","zKey":"true"}'
run /bin/bash -c "dokku config:export --format json-list $TEST_APP"
echo "output: $output"
echo "status: "$stat
assert_output '[{"name":"BKEY","value":"true"},{"name":"aKey","value":"true"},{"name":"bKey","value":"true"},{"name":"zKey","value":"true"}]'
}