support scripts.dokku in app.json. closes #1824

This commit is contained in:
Michael Hobbs
2016-01-06 18:18:57 -08:00
parent 55a4cb3274
commit 48f2dc074c
9 changed files with 200 additions and 2 deletions

View File

@@ -599,3 +599,26 @@ get_app_urls() {
fi
fi
}
get_json_value() {
# return value of provided json key from a json stream on stdin
# JSON_NODE should be expresses as either a top-level object that has no children
# or in the format of json.node.path
local JSON_NODE="$1"
local JSON_NODE=${JSON_NODE//\./\"][\"}
local JSON_NODE="[\"${JSON_NODE}\"]"
cat | python -c 'import json,sys;obj=json.load(sys.stdin);print json.dumps(obj'"${JSON_NODE}"').strip("\"")';
}
get_json_keys() {
# return space-separated list of json keys from json provided on stdin
# JSON_NODE should be expressed as json.node.path and is expected to have children
local JSON_NODE="$1"
local JSON_NODE=${JSON_NODE//\./\"][\"}
local JSON_NODE="[\"${JSON_NODE}\"]"
if [[ "$JSON_NODE" == "[\"\"]" ]]; then
cat | python -c 'import json,sys;obj=json.load(sys.stdin);print " ".join(obj.keys())';
else
cat | python -c 'import json,sys;obj=json.load(sys.stdin);print " ".join(obj'"${JSON_NODE}"'.keys())';
fi
}