Add import, clone commands
Fix dump and connect commands
This commit is contained in:
25
commands
25
commands
@@ -115,15 +115,20 @@ case "$1" in
|
|||||||
SERVICE_NAME="$(get_service_name "$SERVICE")"
|
SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
PASSWORD=$(cat "$SERVICE_ROOT/PASSWORD")
|
PASSWORD=$(cat "$SERVICE_ROOT/PASSWORD")
|
||||||
|
|
||||||
docker exec "$SERVICE_NAME" mysqldump --host=localhost --user=mysql --password="$PASSWORD" --databases "$SERVICE"
|
docker exec "$SERVICE_NAME" mysqldump --user=mysql --password="$PASSWORD" "$SERVICE"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
$PLUGIN_COMMAND_PREFIX:import)
|
$PLUGIN_COMMAND_PREFIX:import)
|
||||||
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
|
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
|
||||||
verify_service_name "$2"
|
verify_service_name "$2"
|
||||||
SERVICE="$2"
|
SERVICE="$2"; SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
|
SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
|
PASSWORD=$(cat "$SERVICE_ROOT/PASSWORD")
|
||||||
|
|
||||||
dokku_log_fail "Not yet implemented"
|
if [[ -t 0 ]]; then
|
||||||
|
dokku_log_fail "No data provided on stdin."
|
||||||
|
fi
|
||||||
|
docker exec -i "$SERVICE_NAME" mysql --user=mysql --password="$PASSWORD" "$SERVICE"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
$PLUGIN_COMMAND_PREFIX:logs)
|
$PLUGIN_COMMAND_PREFIX:logs)
|
||||||
@@ -159,7 +164,7 @@ case "$1" in
|
|||||||
SERVICE_NAME="$(get_service_name "$SERVICE")"
|
SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
|
|
||||||
PASSWORD=$(cat "$SERVICE_ROOT/PASSWORD")
|
PASSWORD=$(cat "$SERVICE_ROOT/PASSWORD")
|
||||||
docker exec -it "$SERVICE_NAME" mysql --host=localhost --user=mysql --password="$PASSWORD" --database="$SERVICE"
|
docker exec -it "$SERVICE_NAME" mysql --user=mysql --password="$PASSWORD" --database="$SERVICE"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
$PLUGIN_COMMAND_PREFIX:info)
|
$PLUGIN_COMMAND_PREFIX:info)
|
||||||
@@ -174,10 +179,14 @@ case "$1" in
|
|||||||
|
|
||||||
$PLUGIN_COMMAND_PREFIX:clone)
|
$PLUGIN_COMMAND_PREFIX:clone)
|
||||||
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
|
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
|
||||||
|
[[ -z $3 ]] && dokku_log_fail "Please specify a name for the new service"
|
||||||
verify_service_name "$2"
|
verify_service_name "$2"
|
||||||
SERVICE="$2"
|
SERVICE="$2"
|
||||||
|
NEW_SERVICE="$3"
|
||||||
dokku_log_fail "Not yet implemented"
|
dokku "$PLUGIN_COMMAND_PREFIX:create" "$NEW_SERVICE"
|
||||||
|
dokku_log_info1 "Copying data from $SERVICE to $NEW_SERVICE"
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:export" "$SERVICE" | dokku "$PLUGIN_COMMAND_PREFIX:import" "$NEW_SERVICE" > /dev/null 2>&1 || true
|
||||||
|
dokku_log_info1 "Done"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
$PLUGIN_COMMAND_PREFIX:expose)
|
$PLUGIN_COMMAND_PREFIX:expose)
|
||||||
@@ -200,13 +209,13 @@ case "$1" in
|
|||||||
$PLUGIN_COMMAND_PREFIX:link <name> <app>, Link the $PLUGIN_SERVICE service to the app
|
$PLUGIN_COMMAND_PREFIX:link <name> <app>, Link the $PLUGIN_SERVICE service to the app
|
||||||
$PLUGIN_COMMAND_PREFIX:unlink <name> <app>, Unlink the $PLUGIN_SERVICE service from the app
|
$PLUGIN_COMMAND_PREFIX:unlink <name> <app>, Unlink the $PLUGIN_SERVICE service from the app
|
||||||
$PLUGIN_COMMAND_PREFIX:export <name>, Export a dump of the $PLUGIN_SERVICE service database
|
$PLUGIN_COMMAND_PREFIX:export <name>, Export a dump of the $PLUGIN_SERVICE service database
|
||||||
$PLUGIN_COMMAND_PREFIX:import <name> <file>, NOT IMPLEMENTED
|
$PLUGIN_COMMAND_PREFIX:import <name> < <file>, Import a dump into the $PLUGIN_SERVICE service database
|
||||||
$PLUGIN_COMMAND_PREFIX:connect <name>, Connect via mysql to a $PLUGIN_SERVICE service
|
$PLUGIN_COMMAND_PREFIX:connect <name>, Connect via mysql to a $PLUGIN_SERVICE service
|
||||||
$PLUGIN_COMMAND_PREFIX:logs <name> [-t], Print the most recent log(s) for this service
|
$PLUGIN_COMMAND_PREFIX:logs <name> [-t], Print the most recent log(s) for this service
|
||||||
$PLUGIN_COMMAND_PREFIX:restart <name>, Graceful shutdown and restart of the $PLUGIN_SERVICE service container
|
$PLUGIN_COMMAND_PREFIX:restart <name>, Graceful shutdown and restart of the $PLUGIN_SERVICE service container
|
||||||
$PLUGIN_COMMAND_PREFIX:info <name>, Print the connection information
|
$PLUGIN_COMMAND_PREFIX:info <name>, Print the connection information
|
||||||
$PLUGIN_COMMAND_PREFIX:list, List all $PLUGIN_SERVICE services
|
$PLUGIN_COMMAND_PREFIX:list, List all $PLUGIN_SERVICE services
|
||||||
$PLUGIN_COMMAND_PREFIX:clone <name> <new-name>, NOT IMPLEMENTED
|
$PLUGIN_COMMAND_PREFIX:clone <name> <new-name>, Create container <new-name> then copy data from <name> into <new-name>
|
||||||
$PLUGIN_COMMAND_PREFIX:expose <name> [port], Expose a $PLUGIN_SERVICE service on custom port if provided (random port otherwise)
|
$PLUGIN_COMMAND_PREFIX:expose <name> [port], Expose a $PLUGIN_SERVICE service on custom port if provided (random port otherwise)
|
||||||
$PLUGIN_COMMAND_PREFIX:unexpose <name>, Unexpose a previously exposed $PLUGIN_SERVICE service
|
$PLUGIN_COMMAND_PREFIX:unexpose <name>, Unexpose a previously exposed $PLUGIN_SERVICE service
|
||||||
$PLUGIN_COMMAND_PREFIX:start <name>, Start a previously stopped $PLUGIN_SERVICE service
|
$PLUGIN_COMMAND_PREFIX:start <name>, Start a previously stopped $PLUGIN_SERVICE service
|
||||||
|
|||||||
42
tests/service_clone.bats
Executable file
42
tests/service_clone.bats
Executable file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
export ECHO_DOCKER_COMMAND="false"
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
export ECHO_DOCKER_COMMAND="false"
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:clone) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:clone"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:clone) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:clone" not_existing_service new_service
|
||||||
|
assert_contains "${lines[*]}" "service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:clone) error when new service isn't provided" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:clone" l
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the new service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:clone) error when new service already exists" {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" new_service
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:clone" l new_service
|
||||||
|
assert_contains "${lines[*]}" "service new_service already exists"
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" new_service
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:clone) success" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:clone" l new_service
|
||||||
|
[[ -f $PLUGIN_DATA_ROOT/new_service/ID ]]
|
||||||
|
assert_contains "${lines[*]}" "Copying data from l to new_service"
|
||||||
|
assert_contains "${lines[*]}" "Done"
|
||||||
|
}
|
||||||
|
|
||||||
@@ -25,6 +25,6 @@ teardown() {
|
|||||||
export ECHO_DOCKER_COMMAND="true"
|
export ECHO_DOCKER_COMMAND="true"
|
||||||
run dokku "$PLUGIN_COMMAND_PREFIX:connect" l
|
run dokku "$PLUGIN_COMMAND_PREFIX:connect" l
|
||||||
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
||||||
assert_output "docker exec -it dokku.mysql.l mysql --host=localhost --user=mysql --password=$password --database=l"
|
assert_output "docker exec -it dokku.mysql.l mysql --user=mysql --password=$password --database=l"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,6 @@ teardown() {
|
|||||||
export ECHO_DOCKER_COMMAND="true"
|
export ECHO_DOCKER_COMMAND="true"
|
||||||
run dokku "$PLUGIN_COMMAND_PREFIX:export" l
|
run dokku "$PLUGIN_COMMAND_PREFIX:export" l
|
||||||
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
||||||
assert_output "docker exec dokku.mysql.l mysqldump --host=localhost --user=mysql --password=$password --databases l"
|
assert_output "docker exec dokku.mysql.l mysqldump --user=mysql --password=$password l"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
37
tests/service_import.bats
Executable file
37
tests/service_import.bats
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
export ECHO_DOCKER_COMMAND="false"
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
echo "data" > "$PLUGIN_DATA_ROOT/fake.sql"
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
export ECHO_DOCKER_COMMAND="false"
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
rm -f "$PLUGIN_DATA_ROOT/fake.sql"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:import) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:import"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:import) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:import" not_existing_service
|
||||||
|
assert_contains "${lines[*]}" "service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:import) error when data is not provided" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:import" l
|
||||||
|
assert_contains "${lines[*]}" "No data provided on stdin"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:import) success" {
|
||||||
|
export ECHO_DOCKER_COMMAND="true"
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:import" l < "$PLUGIN_DATA_ROOT/fake.sql"
|
||||||
|
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
||||||
|
assert_output "docker exec -i dokku.mysql.l mysql --user=mysql --password=$password l"
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user