feat: implement exists and linked subcommands
This commit is contained in:
11
.travis.yml
11
.travis.yml
@@ -2,10 +2,9 @@ sudo: required
|
|||||||
dist: trusty
|
dist: trusty
|
||||||
language: bash
|
language: bash
|
||||||
env:
|
env:
|
||||||
- DOKKU_VERSION=master
|
- DOKKU_VERSION=master DOKKU_SYSTEM_GROUP=travis DOKKU_SYSTEM_USER=travis
|
||||||
- DOKKU_VERSION=v0.7.0
|
- DOKKU_VERSION=v0.7.0 DOKKU_SYSTEM_GROUP=travis DOKKU_SYSTEM_USER=travis
|
||||||
- DOKKU_VERSION=v0.6.0
|
- DOKKU_VERSION=v0.6.0 DOKKU_SYSTEM_GROUP=travis DOKKU_SYSTEM_USER=travis
|
||||||
- DOKKU_VERSION=v0.5.0
|
- DOKKU_VERSION=v0.5.0 DOKKU_SYSTEM_GROUP=travis DOKKU_SYSTEM_USER=travis
|
||||||
- DOKKU_VERSION=v0.4.0
|
- DOKKU_VERSION=v0.4.0 DOKKU_SYSTEM_GROUP=travis DOKKU_SYSTEM_USER=travis
|
||||||
before_install: make setup
|
|
||||||
script: make test
|
script: make test
|
||||||
|
|||||||
@@ -29,11 +29,13 @@ postgres:connect <name> Connect via psql to a postgres service
|
|||||||
postgres:create <name> Create a postgres service with environment variables
|
postgres:create <name> Create a postgres service with environment variables
|
||||||
postgres:destroy <name> Delete the service, delete the data and stop its container if there are no links left
|
postgres:destroy <name> Delete the service, delete the data and stop its container if there are no links left
|
||||||
postgres:enter <name> [command] Enter or run a command in a running postgres service container
|
postgres:enter <name> [command] Enter or run a command in a running postgres service container
|
||||||
|
postgres:exists <service> Check if the postgres service exists
|
||||||
postgres:export <name> > <file> Export a dump of the postgres service database
|
postgres:export <name> > <file> Export a dump of the postgres service database
|
||||||
postgres:expose <name> [port] Expose a postgres service on custom port if provided (random port otherwise)
|
postgres:expose <name> [port] Expose a postgres service on custom port if provided (random port otherwise)
|
||||||
postgres:import <name> < <file> Import a dump into the postgres service database
|
postgres:import <name> < <file> Import a dump into the postgres service database
|
||||||
postgres:info <name> Print the connection information
|
postgres:info <name> Print the connection information
|
||||||
postgres:link <name> <app> Link the postgres service to the app
|
postgres:link <name> <app> Link the postgres service to the app
|
||||||
|
postgres:linked <name> <app> Check if the postgres service is linked to an app
|
||||||
postgres:list List all postgres services
|
postgres:list List all postgres services
|
||||||
postgres:logs <name> [-t] Print the most recent log(s) for this service
|
postgres:logs <name> [-t] Print the most recent log(s) for this service
|
||||||
postgres:promote <name> <app> Promote service <name> as DATABASE_URL in <app>
|
postgres:promote <name> <app> Promote service <name> as DATABASE_URL in <app>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
docker_ports_options() {
|
docker_ports_options() {
|
||||||
declare desc="Exports a list of exposed ports"
|
declare desc="Exports a list of exposed ports"
|
||||||
@@ -288,6 +289,20 @@ service_info() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service_is_linked() {
|
||||||
|
declare desc="Links a service to an application"
|
||||||
|
declare SERVICE="$1" APP="$2"
|
||||||
|
update_plugin_scheme_for_app "$APP"
|
||||||
|
local SERVICE_URL=$(service_url "$SERVICE")
|
||||||
|
local EXISTING_CONFIG=$(config_all "$APP")
|
||||||
|
local LINK=$(echo "$EXISTING_CONFIG" | grep "$SERVICE_URL" | cut -d: -f1) || true
|
||||||
|
if [[ -z $LINK ]]; then
|
||||||
|
dokku_log_warn "Service $SERVICE is not linked to $APP"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
dokku_log_info1 "Service $SERVICE is linked to $APP"
|
||||||
|
}
|
||||||
|
|
||||||
service_link() {
|
service_link() {
|
||||||
declare desc="Links a service to an application"
|
declare desc="Links a service to an application"
|
||||||
declare SERVICE="$1" APP="$2"
|
declare SERVICE="$1" APP="$2"
|
||||||
|
|||||||
20
subcommands/exists
Executable file
20
subcommands/exists
Executable 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 "$@"
|
||||||
24
subcommands/linked
Executable file
24
subcommands/linked
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-linked-cmd() {
|
||||||
|
#E here we check if the lolipop $PLUGIN_COMMAND_PREFIX service is linked to the 'playground' app.
|
||||||
|
#E dokku $PLUGIN_COMMAND_PREFIX:linked lolipop playground
|
||||||
|
#A service, service to run command against
|
||||||
|
#A app, app to run command against
|
||||||
|
declare desc="check if the $PLUGIN_SERVICE service is linked to an app"
|
||||||
|
local cmd="$PLUGIN_COMMAND_PREFIX:linked" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||||
|
declare SERVICE="$1" APP="$2"
|
||||||
|
APP=${APP:="$DOKKU_APP_NAME"}
|
||||||
|
|
||||||
|
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
|
||||||
|
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||||
|
verify_app_name "$APP"
|
||||||
|
verify_service_name "$SERVICE"
|
||||||
|
service_is_linked "$SERVICE" "$APP"
|
||||||
|
}
|
||||||
|
|
||||||
|
service-linked-cmd "$@"
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/test_helper.bash"
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/test_helper.bash"
|
||||||
|
|
||||||
BIN_STUBS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/bin"
|
BIN_STUBS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/bin"
|
||||||
@@ -10,6 +11,11 @@ fi
|
|||||||
cd $DOKKU_ROOT
|
cd $DOKKU_ROOT
|
||||||
echo "Dokku version $DOKKU_VERSION"
|
echo "Dokku version $DOKKU_VERSION"
|
||||||
git checkout $DOKKU_VERSION > /dev/null
|
git checkout $DOKKU_VERSION > /dev/null
|
||||||
|
if grep go-build Makefile > /dev/null; then
|
||||||
|
mv "$BIN_STUBS/docker" "$BIN_STUBS/docker-stub"
|
||||||
|
make go-build
|
||||||
|
mv "$BIN_STUBS/docker-stub" "$BIN_STUBS/docker"
|
||||||
|
fi
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export PLUGIN_CORE_AVAILABLE_PATH="$PLUGIN_PATH"
|
|||||||
export POSTGRES_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/fixtures"
|
export POSTGRES_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/fixtures"
|
||||||
export PLUGIN_DATA_ROOT="$POSTGRES_ROOT"
|
export PLUGIN_DATA_ROOT="$POSTGRES_ROOT"
|
||||||
export PLUGIN_CONFIG_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
|
export PLUGIN_CONFIG_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
|
||||||
|
export DOKKU_LIB_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib-root"
|
||||||
if [[ "$(uname)" == "Darwin" ]]; then
|
if [[ "$(uname)" == "Darwin" ]]; then
|
||||||
export PLUGN_URL="https://github.com/dokku/plugn/releases/download/v0.3.0/plugn_0.3.0_darwin_x86_64.tgz"
|
export PLUGN_URL="https://github.com/dokku/plugn/releases/download/v0.3.0/plugn_0.3.0_darwin_x86_64.tgz"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user