fix: ensure the new service does not exist when cloning an existing service
This commit is contained in:
@@ -411,6 +411,14 @@ service_enter() {
|
|||||||
docker exec $DOKKU_RUN_OPTS $ID $EXEC_CMD "${@:-/bin/bash}"
|
docker exec $DOKKU_RUN_OPTS $ID $EXEC_CMD "${@:-/bin/bash}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service_exists() {
|
||||||
|
declare desc="returns 0 or 1 depending on whether service exists or not"
|
||||||
|
declare SERVICE="$1"
|
||||||
|
[[ -z "$SERVICE" ]] && return 1
|
||||||
|
[[ -d "$PLUGIN_DATA_ROOT/$SERVICE" ]] && return 0
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
service_exposed_ports() {
|
service_exposed_ports() {
|
||||||
declare desc="list exposed ports for a service"
|
declare desc="list exposed ports for a service"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ service-clone-cmd() {
|
|||||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
||||||
[[ -z "$NEW_SERVICE" ]] && dokku_log_fail "Please specify a name for the new service"
|
[[ -z "$NEW_SERVICE" ]] && dokku_log_fail "Please specify a name for the new service"
|
||||||
verify_service_name "$SERVICE"
|
verify_service_name "$SERVICE"
|
||||||
|
if service_exists "$NEW_SERVICE"; then
|
||||||
|
dokku_log_fail "Invalid service name $NEW_SERVICE. Verify the service name is not already in use."
|
||||||
|
fi
|
||||||
|
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local ID="$(cat "$SERVICE_ROOT/ID")"
|
local ID="$(cat "$SERVICE_ROOT/ID")"
|
||||||
|
|||||||
Reference in New Issue
Block a user