From 4e3a77ab0edae32e4c403f3d98e2c7d462253785 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 25 Jul 2022 01:30:32 -0400 Subject: [PATCH] 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. --- service-list | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 service-list diff --git a/service-list b/service-list new file mode 100755 index 0000000..6fc54e9 --- /dev/null +++ b/service-list @@ -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 "$@"