Skip to content

Commit 3357ca9

Browse files
committed
Show users and databases in list output
1 parent d6c838e commit 3357ca9

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

commands

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ case "$1" in
5151
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/destroy" "$@"
5252
;;
5353

54+
$PLUGIN_COMMAND_PREFIX:destroy-database)
55+
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/destroy-database" "$@"
56+
;;
57+
5458
$PLUGIN_COMMAND_PREFIX:export)
5559
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/subcommands/export" "$@"
5660
;;
@@ -118,6 +122,7 @@ case "$1" in
118122
$PLUGIN_COMMAND_PREFIX:create <name>, Create a $PLUGIN_SERVICE service
119123
$PLUGIN_COMMAND_PREFIX:create-database <name> <db>, Create a $PLUGIN_SERVICE database in the specified service
120124
$PLUGIN_COMMAND_PREFIX:destroy <name>, Delete the $PLUGIN_SERVICE service and stop its container if there are no links left
125+
$PLUGIN_COMMAND_PREFIX:destroy-database <name> <db>, Delete a $PLUGIN_SERVICE database on the specified service
121126
$PLUGIN_COMMAND_PREFIX:export <name>, Export a dump of the $PLUGIN_SERVICE service database
122127
$PLUGIN_COMMAND_PREFIX:expose <name> [port], Expose a $PLUGIN_SERVICE service on custom port if provided (random port otherwise)
123128
$PLUGIN_COMMAND_PREFIX:import <name> < <file>, Import a dump into the $PLUGIN_SERVICE service database

common-functions

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,28 @@ service_exposed_ports() {
192192
done
193193
}
194194

195+
service_databases() {
196+
declare desc="Lists databases for a service"
197+
declare SERVICE="$1"
198+
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
199+
local DATABASE_DIR="$SERVICE_ROOT/databases"
200+
[[ ! -d $DATABASE_DIR ]] && echo '-' && return 0
201+
for DATABASE in $DATABASE_DIR/*; do
202+
echo -n "$(basename "$DATABASE") "
203+
done
204+
}
205+
206+
service_users() {
207+
declare desc="Lists users for a service"
208+
declare SERVICE="$1"
209+
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
210+
local USER_DIR="$SERVICE_ROOT/auth"
211+
[[ ! -d $USER_DIR ]] && echo '-' && return 0
212+
for USER in $USER_DIR/*; do
213+
echo -n "$(basename "$USER") "
214+
done
215+
}
216+
195217
service_info() {
196218
declare desc="Retrieves information about a given service"
197219
declare SERVICE="$1" INFO_FLAG="$2"
@@ -287,9 +309,9 @@ service_list() {
287309
if [[ -z $SERVICES ]]; then
288310
dokku_log_warn "There are no $PLUGIN_SERVICE services"
289311
else
290-
LIST="NAME,VERSION,STATUS,EXPOSED PORTS,LINKS\n"
312+
LIST="NAME,VERSION,STATUS,EXPOSED PORTS,DATABASES,USERS,LINKS\n"
291313
for SERVICE in $SERVICES; do
292-
LIST+="$SERVICE,$(service_version "$SERVICE"),$(service_status "$SERVICE"),$(service_exposed_ports "$SERVICE"),$(service_linked_apps "$SERVICE")\n"
314+
LIST+="$SERVICE,$(service_version "$SERVICE"),$(service_status "$SERVICE"),$(service_exposed_ports "$SERVICE"),$(service_databases "$SERVICE"),$(service_users "$SERVICE"),$(service_linked_apps "$SERVICE")\n"
293315
done
294316
printf "%b" "$LIST" | column -t -s,
295317
fi

0 commit comments

Comments
 (0)