feat: add sigil templating to CHECKS files
This enables general templating capabilities, in addition to environment variable access. Closes #3974.
This commit is contained in:
@@ -6,6 +6,10 @@ app.get('/', function(request, response) {
|
||||
response.send('nodejs/express');
|
||||
});
|
||||
|
||||
app.get('/healthcheck', function(request, response) {
|
||||
response.send(process.env.HEALTHCHECK_ENDPOINT);
|
||||
});
|
||||
|
||||
var port = process.env.PORT || 5000;
|
||||
app.listen(port, function() {
|
||||
console.log("Listening on " + port);
|
||||
|
||||
@@ -249,3 +249,16 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(checks) checks:templated" {
|
||||
run /bin/bash -c "dokku config:set $TEST_APP HEALTHCHECK_ENDPOINT=/healthcheck"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run deploy_app nodejs-express dokku@dokku.me:$TEST_APP template_checks_file
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output_contains "/healthcheck" 2
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -484,6 +484,20 @@ some lame nginx config
|
||||
EOF
|
||||
}
|
||||
|
||||
template_checks_file() {
|
||||
local APP="$1"
|
||||
local APP_REPO_DIR="$2"
|
||||
[[ -z "$APP" ]] && local APP="$TEST_APP"
|
||||
echo "injecting templated CHECKS file -> $APP_REPO_DIR/CHECKS"
|
||||
cat <<EOF >"$APP_REPO_DIR/CHECKS"
|
||||
WAIT=2 # wait 2 seconds
|
||||
TIMEOUT=5 # set timeout to 5 seconds
|
||||
ATTEMPTS=2 # try 2 times
|
||||
|
||||
{{ var "HEALTHCHECK_ENDPOINT" }} {{ var "HEALTHCHECK_ENDPOINT" }}
|
||||
EOF
|
||||
}
|
||||
|
||||
add_release_command() {
|
||||
local APP="$1"
|
||||
local APP_REPO_DIR="$2"
|
||||
|
||||
Reference in New Issue
Block a user