2016-02-08 23:30:36 -05:00
|
|
|
#!/usr/bin/env bash
|
2019-01-07 01:04:17 -05:00
|
|
|
set -eo pipefail
|
|
|
|
|
[[ $DOKKU_TRACE ]] && set -x
|
2015-09-09 18:27:42 -07:00
|
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
2015-08-30 01:55:14 -04:00
|
|
|
|
2017-12-02 13:55:34 -05:00
|
|
|
config_sub() {
|
2017-02-18 15:56:31 -05:00
|
|
|
declare desc="executes a config subcommand"
|
|
|
|
|
local name="$1"
|
|
|
|
|
shift
|
2022-05-21 14:42:01 -04:00
|
|
|
"$PLUGIN_AVAILABLE_PATH/config/config_sub" "$name" "$@"
|
2017-02-18 15:56:31 -05:00
|
|
|
}
|
|
|
|
|
|
2015-08-30 01:55:14 -04:00
|
|
|
config_export() {
|
2016-03-08 15:30:34 -05:00
|
|
|
declare desc="returns export command for config variable of specified type (app/global)"
|
2015-08-30 01:55:14 -04:00
|
|
|
local CONFIG_TYPE="$1"
|
2017-02-18 15:56:31 -05:00
|
|
|
shift
|
|
|
|
|
local APP="$1"
|
2017-01-16 23:13:32 -05:00
|
|
|
if [[ $CONFIG_TYPE == "global" ]]; then
|
|
|
|
|
APP="--global"
|
2017-02-18 15:56:31 -05:00
|
|
|
else
|
|
|
|
|
shift
|
2015-08-31 23:08:28 -04:00
|
|
|
fi
|
2017-02-18 15:56:31 -05:00
|
|
|
config_sub export "$@" "$APP"
|
2017-01-16 23:13:32 -05:00
|
|
|
return 0
|
2015-09-01 14:30:32 -04:00
|
|
|
}
|
|
|
|
|
|
2017-12-02 13:55:34 -05:00
|
|
|
config_all() {
|
|
|
|
|
declare desc="Backwards compatible function for plugin use"
|
2017-12-13 17:37:29 -05:00
|
|
|
[[ "$1" == "config" ]] || set -- "config" "$@"
|
2017-12-13 17:17:10 -05:00
|
|
|
if [[ -n "$DOKKU_CONFIG_EXPORT" ]]; then
|
2017-12-13 15:46:53 -05:00
|
|
|
config_export app "$@"
|
2017-12-02 13:55:34 -05:00
|
|
|
return 0
|
|
|
|
|
fi
|
2017-12-13 17:37:29 -05:00
|
|
|
|
2020-07-18 16:20:00 +02:00
|
|
|
"$PLUGIN_AVAILABLE_PATH/config/subcommands/show" "$@"
|
2017-12-02 13:55:34 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-30 22:20:39 -05:00
|
|
|
config_keys() {
|
|
|
|
|
declare desc="returns keys for app or global"
|
2017-11-03 12:42:00 +09:00
|
|
|
config_sub keys "$@"
|
2017-01-30 22:20:39 -05:00
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 00:52:40 -04:00
|
|
|
config_get() {
|
2016-03-08 15:30:34 -05:00
|
|
|
declare desc="get value of given config var"
|
2017-02-18 15:56:31 -05:00
|
|
|
config_sub get "$@"
|
2015-09-01 00:52:40 -04:00
|
|
|
}
|
|
|
|
|
|
2019-05-20 13:25:04 -07:00
|
|
|
config_clear() {
|
|
|
|
|
declare desc="clears config vars"
|
|
|
|
|
config_sub clear "$@"
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 00:52:40 -04:00
|
|
|
config_set() {
|
2016-03-08 15:30:34 -05:00
|
|
|
declare desc="set value of given config var"
|
2017-02-18 15:56:31 -05:00
|
|
|
config_sub set "$@"
|
2015-09-01 00:52:40 -04:00
|
|
|
}
|
2015-09-01 14:30:32 -04:00
|
|
|
|
|
|
|
|
config_unset() {
|
2017-11-03 12:42:00 +09:00
|
|
|
declare desc="unset value of given config var"
|
2017-02-18 15:56:31 -05:00
|
|
|
config_sub unset "$@"
|
2015-09-01 14:30:32 -04:00
|
|
|
}
|
2017-05-20 14:38:27 -04:00
|
|
|
|
|
|
|
|
config_bundle() {
|
|
|
|
|
declare desc="export tar bundle of config"
|
|
|
|
|
config_sub bundle "$@"
|
|
|
|
|
}
|