Files
dokku/plugins/storage/functions
Jose Diaz-Gonzalez 852dfc6287 feat: add json output format support to storage:list
This will allow the command to be used in a programmatic fashion.
2022-12-26 16:33:40 -05:00

32 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_AVAILABLE_PATH/docker-options/functions"
verify_paths() {
declare desc="verifies storage paths"
local -r passed_path=$1
if [[ "$passed_path" == /* ]]; then
echo "$passed_path" | grep -qe '^/.*\:/' || dokku_log_fail "Storage path must be two valid paths divided by colon."
else
echo "$passed_path" | grep -qe '^[a-zA-Z0-9]\{1\}[a-zA-Z0-9_.-]\+\:\/' || dokku_log_fail "Volume name must be two characters or more. Volume name must not contain invalid characters. Storage path must be two valid paths divided by colon."
fi
}
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
if [[ -r "$phase_file_path" ]]; then
sed -e '/^-v/!d' -e 's/^-v //' <"$phase_file_path"
fi
}