feat: add service:links command
This allows users to script against apps that are linked to a given service
This commit is contained in:
@@ -468,7 +468,7 @@ service_link() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
service_linked_apps() {
|
service_linked_apps() {
|
||||||
declare desc="Lists all applications linked to a service"
|
declare desc="Lists all apps linked to a service for info output"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local LINKS_FILE="$SERVICE_ROOT/LINKS"
|
local LINKS_FILE="$SERVICE_ROOT/LINKS"
|
||||||
@@ -479,6 +479,18 @@ service_linked_apps() {
|
|||||||
tr '\n' ' ' <"$LINKS_FILE"
|
tr '\n' ' ' <"$LINKS_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service_links() {
|
||||||
|
declare desc="Lists all apps linked to a service"
|
||||||
|
declare SERVICE="$1"
|
||||||
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
|
local LINKS_FILE="$SERVICE_ROOT/LINKS"
|
||||||
|
|
||||||
|
touch "$LINKS_FILE"
|
||||||
|
[[ -z $(<"$LINKS_FILE") ]] && return 0
|
||||||
|
|
||||||
|
cat "$LINKS_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
service_list() {
|
service_list() {
|
||||||
declare desc="Lists all services and their status"
|
declare desc="Lists all services and their status"
|
||||||
local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
|
local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
|
||||||
|
|||||||
24
subcommands/links
Executable file
24
subcommands/links
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||||
|
set -eo pipefail
|
||||||
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_BASE_PATH/common/functions"
|
||||||
|
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||||
|
|
||||||
|
service-links-cmd() {
|
||||||
|
#E list all apps linked to the 'lolipop' $PLUGIN_COMMAND_PREFIX service.
|
||||||
|
#E dokku $PLUGIN_COMMAND_PREFIX:links lolipop
|
||||||
|
#A service, service to run command against
|
||||||
|
declare desc="list all apps linked to the $PLUGIN_SERVICE service"
|
||||||
|
local cmd="$PLUGIN_COMMAND_PREFIX:links" argv=("$@")
|
||||||
|
[[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||||
|
declare SERVICE="$1"
|
||||||
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
|
local LINKS_FILE="$SERVICE_ROOT/LINKS"
|
||||||
|
|
||||||
|
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
||||||
|
verify_service_name "$SERVICE"
|
||||||
|
service_links "$SERVICE"
|
||||||
|
}
|
||||||
|
|
||||||
|
service-links-cmd "$@"
|
||||||
Reference in New Issue
Block a user