Alphabetize functions
This commit is contained in:
@@ -9,6 +9,20 @@ docker_ports_options() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_container_ip() {
|
||||||
|
declare desc="Retrieves the ip address of a container"
|
||||||
|
declare CONTAINER_ID="$1"
|
||||||
|
docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$CONTAINER_ID"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_database_name() {
|
||||||
|
declare desc="Retrieves a sanitized database name"
|
||||||
|
declare DATABASE="$1"
|
||||||
|
# some datastores do not like special characters in database names
|
||||||
|
# so we need to normalize them out
|
||||||
|
echo "$DATABASE" | tr .- _
|
||||||
|
}
|
||||||
|
|
||||||
get_random_ports() {
|
get_random_ports() {
|
||||||
declare desc="Retrieves N random ports"
|
declare desc="Retrieves N random ports"
|
||||||
declare iterations="${1:-1}"
|
declare iterations="${1:-1}"
|
||||||
@@ -27,20 +41,6 @@ get_random_ports() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_container_ip() {
|
|
||||||
declare desc="Retrieves the ip address of a container"
|
|
||||||
declare CONTAINER_ID="$1"
|
|
||||||
docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$CONTAINER_ID"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_database_name() {
|
|
||||||
declare desc="Retrieves a sanitized database name"
|
|
||||||
declare DATABASE="$1"
|
|
||||||
# some datastores do not like special characters in database names
|
|
||||||
# so we need to normalize them out
|
|
||||||
echo "$DATABASE" | tr .- _
|
|
||||||
}
|
|
||||||
|
|
||||||
get_service_name() {
|
get_service_name() {
|
||||||
declare desc="Retrieves a docker service label"
|
declare desc="Retrieves a docker service label"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
@@ -77,14 +77,6 @@ remove_from_links_file() {
|
|||||||
sort "$LINKS_FILE" -u -o "$LINKS_FILE"
|
sort "$LINKS_FILE" -u -o "$LINKS_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
verify_service_name() {
|
|
||||||
declare desc="Verifies that a service exists"
|
|
||||||
declare SERVICE="$1"
|
|
||||||
[[ ! -n "$SERVICE" ]] && dokku_log_fail "(verify_service_name) SERVICE must not be null"
|
|
||||||
[[ ! -d "$PLUGIN_DATA_ROOT/$SERVICE" ]] && dokku_log_fail "$PLUGIN_SERVICE service $SERVICE does not exist"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
service_alias() {
|
service_alias() {
|
||||||
declare desc="Retrieves the alias of a service"
|
declare desc="Retrieves the alias of a service"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
@@ -235,31 +227,6 @@ service_logs() {
|
|||||||
docker logs $DOKKU_LOGS_ARGS "$ID"
|
docker logs $DOKKU_LOGS_ARGS "$ID"
|
||||||
}
|
}
|
||||||
|
|
||||||
service_set_alias() {
|
|
||||||
declare desc="Sets the alias in use for a service"
|
|
||||||
declare SERVICE="$1" ALIAS="$2"
|
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
|
||||||
local ALIAS_FILE="$SERVICE_ROOT/ALIAS"
|
|
||||||
|
|
||||||
mkdir -p "$SERVICE_ROOT" || dokku_log_fail "Unable to create service directory"
|
|
||||||
touch "$ALIAS_FILE"
|
|
||||||
echo "$ALIAS" > "$ALIAS_FILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
service_status() {
|
|
||||||
declare desc="Displays the status of a service"
|
|
||||||
declare SERVICE="$1"
|
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
|
||||||
local ID="$(cat "$SERVICE_ROOT/ID")"
|
|
||||||
|
|
||||||
is_container_status "$ID" "Dead" && echo "dead" && return 0
|
|
||||||
is_container_status "$ID" "OOMKilled" && echo "oomkilled" && return 0
|
|
||||||
is_container_status "$ID" "Paused" && echo "paused" && return 0
|
|
||||||
is_container_status "$ID" "Restarting" && echo "restarting" && return 0
|
|
||||||
is_container_status "$ID" "Running" && echo "running" && return 0
|
|
||||||
echo "stopped" && return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
service_port_expose() {
|
service_port_expose() {
|
||||||
declare desc="Wrapper for exposing service ports"
|
declare desc="Wrapper for exposing service ports"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
@@ -355,6 +322,31 @@ service_promote() {
|
|||||||
config_set "$APP" $NEW_CONFIG_VARS
|
config_set "$APP" $NEW_CONFIG_VARS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service_set_alias() {
|
||||||
|
declare desc="Sets the alias in use for a service"
|
||||||
|
declare SERVICE="$1" ALIAS="$2"
|
||||||
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
|
local ALIAS_FILE="$SERVICE_ROOT/ALIAS"
|
||||||
|
|
||||||
|
mkdir -p "$SERVICE_ROOT" || dokku_log_fail "Unable to create service directory"
|
||||||
|
touch "$ALIAS_FILE"
|
||||||
|
echo "$ALIAS" > "$ALIAS_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
service_status() {
|
||||||
|
declare desc="Displays the status of a service"
|
||||||
|
declare SERVICE="$1"
|
||||||
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
|
local ID="$(cat "$SERVICE_ROOT/ID")"
|
||||||
|
|
||||||
|
is_container_status "$ID" "Dead" && echo "dead" && return 0
|
||||||
|
is_container_status "$ID" "OOMKilled" && echo "oomkilled" && return 0
|
||||||
|
is_container_status "$ID" "Paused" && echo "paused" && return 0
|
||||||
|
is_container_status "$ID" "Restarting" && echo "restarting" && return 0
|
||||||
|
is_container_status "$ID" "Running" && echo "running" && return 0
|
||||||
|
echo "stopped" && return 0
|
||||||
|
}
|
||||||
|
|
||||||
service_stop() {
|
service_stop() {
|
||||||
declare desc="Stops a running service"
|
declare desc="Stops a running service"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
@@ -402,3 +394,11 @@ service_version() {
|
|||||||
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
docker inspect -f '{{.Config.Image}}' "$SERVICE_NAME"
|
docker inspect -f '{{.Config.Image}}' "$SERVICE_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verify_service_name() {
|
||||||
|
declare desc="Verifies that a service exists"
|
||||||
|
declare SERVICE="$1"
|
||||||
|
[[ ! -n "$SERVICE" ]] && dokku_log_fail "(verify_service_name) SERVICE must not be null"
|
||||||
|
[[ ! -d "$PLUGIN_DATA_ROOT/$SERVICE" ]] && dokku_log_fail "$PLUGIN_SERVICE service $SERVICE does not exist"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user