feat: add method for listing all plugin services

This will allow other plugins to iterate over the services exposed by a plugin and instantiate whatever is necessary for those services.
This commit is contained in:
Jose Diaz-Gonzalez
2022-07-25 01:30:32 -04:00
parent 41388718a1
commit 07d157e236

20
service-list Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
plugin-service-list() {
declare desc="allows listing all services for use by other dokku plugins"
declare SERVICE_TYPE="$1"
if [[ -n "$SERVICE_TYPE" ]] && [[ "$SERVICE_TYPE" != "$PLUGIN_COMMAND_PREFIX" ]]; then
return
fi
for service in $(fn-services-list false); do
echo "$PLUGIN_COMMAND_PREFIX:$service"
done
}
plugin-service-list "$@"