feat: allow checking if a service exists

This commit is contained in:
Jose Diaz-Gonzalez
2018-01-12 12:26:34 -05:00
parent 0eeb17823c
commit 26be34feb7
2 changed files with 21 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ mysql:connect <name> Connect via mysql to a mysql service
mysql:create <name> Create a mysql service with environment variables
mysql:destroy <name> Delete the service, delete the data and stop its container if there are no links left
mysql:enter <name> [command] Enter or run a command in a running mysql service container
mysql:exists <service> Check if the MySQL service exists
mysql:export <name> > <file> Export a dump of the mysql service database
mysql:expose <name> [port] Expose a mysql service on custom port if provided (random port otherwise)
mysql:import <name> < <file> Import a dump into the mysql service database

20
subcommands/exists Executable file
View File

@@ -0,0 +1,20 @@
#!/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-exists-cmd() {
#E here we check if the lolipop $PLUGIN_COMMAND_PREFIX service exists.
#E dokku $PLUGIN_COMMAND_PREFIX:exists lolipop
#A service, service to run command against
declare desc="check if the $PLUGIN_SERVICE service exists"
local cmd="$PLUGIN_COMMAND_PREFIX:exists" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
declare SERVICE="$1"
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
verify_service_name "$SERVICE"
dokku_log_info1 "Service $SERVICE exists"
}
service-exists-cmd "$@"