Files
dokku/plugins/storage/functions
Jose Diaz-Gonzalez 48503e9f40 fix: add missing import
2017-03-12 21:28:29 -06:00

33 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions"
storage_list_cmd() {
declare desc="List all bound mounts"
local cmd="storage:list"
local passed_phases="deploy"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2" && local APP="$2"
echo "$APP volume bind-mounts:"
get_bind_mounts "$(get_phase_file_path "$passed_phases")"
}
verify_paths() {
declare desc="verifies storage paths"
echo "$1" | grep -qe '^/.*\:/' || dokku_log_fail "Storage path must be two valid paths divided by colon."
}
check_if_path_exists() {
declare desc="checks if path exists"
local -r passed_path=$1
local -r phase_file_path=$2
[[ -r "$phase_file_path" ]] && grep -qe "^-v $passed_path" "$phase_file_path"
}
get_bind_mounts() {
declare desc="strips docker options and prints mounts"
local -r phase_file_path=$1
[[ -r "$phase_file_path" ]] && sed -e '/^-v/!d' -e 's/^-v/ /' < "$phase_file_path"
}