tests: run mvdan/shfmt on test runs
While I do not agree with _every_ style change, this will force Dokku to have consistent formatting across all shell scripts, which is arguably a Good Thing™. The command used to reprocess everything is: ```shell shfmt -l -bn -ci -i 2 -w . ```
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
[[ " help docker-options:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
docker_options_help_content_func() {
|
||||
declare desc="return docker-options plugin help content"
|
||||
cat<<help_content
|
||||
declare desc="return docker-options plugin help content"
|
||||
cat <<help_content
|
||||
docker-options <app> [phase(s)], [DEPRECATED] Alternative for docker-options:report
|
||||
docker-options:add <app> <phase(s)> OPTION, Add Docker option to app for phase (comma separated phase list)
|
||||
docker-options:remove <app> <phase(s)> OPTION, Remove Docker option from app for phase (comma separated phase list)
|
||||
@@ -13,7 +14,7 @@ help_content
|
||||
}
|
||||
|
||||
docker_options_help_cmd() {
|
||||
if [[ $1 = "docker-options:help" ]] ; then
|
||||
if [[ $1 == "docker-options:help" ]]; then
|
||||
echo -e 'Usage: dokku docker-options[:COMMAND]'
|
||||
echo ''
|
||||
echo 'Display app'"'"'s Docker options for all phases.'
|
||||
@@ -23,7 +24,7 @@ docker_options_help_cmd() {
|
||||
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
|
||||
docker_options_help_content_func
|
||||
else
|
||||
cat<<help_desc
|
||||
cat <<help_desc
|
||||
docker-options, Pass options to Docker the various stages of an app
|
||||
help_desc
|
||||
fi
|
||||
@@ -32,10 +33,10 @@ help_desc
|
||||
case "$1" in
|
||||
help | docker-options:help)
|
||||
docker_options_help_cmd "$@"
|
||||
;;
|
||||
;;
|
||||
|
||||
*)
|
||||
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
;;
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
docker_args() {
|
||||
declare desc="docker args plugin trigger"
|
||||
local trigger="$0"
|
||||
local STDIN=$(cat)
|
||||
local APP="$1"; local IMAGE_SOURCE_TYPE="$2"
|
||||
local APP="$1"
|
||||
local IMAGE_SOURCE_TYPE="$2"
|
||||
|
||||
case "$0" in
|
||||
*docker-args-build)
|
||||
@@ -41,26 +43,26 @@ docker_args() {
|
||||
case "$IMAGE_SOURCE_TYPE" in
|
||||
dockerfile)
|
||||
case "$line" in
|
||||
--link*|-v*)
|
||||
--link* | -v*)
|
||||
continue
|
||||
;;
|
||||
|
||||
*)
|
||||
local output="$output $line"
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
;;
|
||||
|
||||
herokuish)
|
||||
case "$line" in
|
||||
--file*|--build-args*)
|
||||
--file* | --build-args*)
|
||||
continue
|
||||
;;
|
||||
|
||||
*)
|
||||
local output="$output $line"
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
;;
|
||||
|
||||
*)
|
||||
@@ -69,7 +71,7 @@ docker_args() {
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done < "$PHASE_FILE_PATH"
|
||||
done <"$PHASE_FILE_PATH"
|
||||
fi
|
||||
|
||||
echo -n "$STDIN$output"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
AVAILABLE_PHASES=(build deploy run)
|
||||
@@ -22,15 +23,16 @@ get_phase_file_path() {
|
||||
get_phases() {
|
||||
declare desc="returns array of passed passes if all are in allowed array"
|
||||
local passed_phases_list="$1"
|
||||
local -r phases_allowed=$(sed -e 's/ /\|/g' <<< "${AVAILABLE_PHASES[@]}")
|
||||
local -r phases_allowed=$(sed -e 's/ /\|/g' <<<"${AVAILABLE_PHASES[@]}")
|
||||
local phase
|
||||
local passed_phases
|
||||
if [[ -n "$passed_phases_list" ]]; then
|
||||
OIFS=$IFS; IFS=','
|
||||
read -ra passed_phases <<< "$passed_phases_list"
|
||||
OIFS=$IFS
|
||||
IFS=','
|
||||
read -ra passed_phases <<<"$passed_phases_list"
|
||||
IFS=$OIFS
|
||||
for phase in "${passed_phases[@]}"; do
|
||||
[[ "$phase" = @($phases_allowed) ]] || dokku_log_fail "Phase(s) must be one of [${AVAILABLE_PHASES[*]}]"
|
||||
[[ "$phase" == @($phases_allowed) ]] || dokku_log_fail "Phase(s) must be one of [${AVAILABLE_PHASES[*]}]"
|
||||
done
|
||||
echo "${passed_phases[@]}"
|
||||
fi
|
||||
@@ -58,7 +60,7 @@ display_all_phases_options() {
|
||||
for phase in "${phases[@]}"; do
|
||||
local phase_file_path="$(get_phase_file_path "$phase")"
|
||||
if [[ -s "$phase_file_path" ]]; then
|
||||
display_phase_options "$phase" "$phase_file_path"
|
||||
display_phase_options "$phase" "$phase_file_path"
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -86,9 +88,9 @@ add_passed_docker_option() {
|
||||
for phase in "${passed_phases[@]}"; do
|
||||
local phase_file_path="$(get_phase_file_path "$phase")"
|
||||
create_phase_file_if_required "$phase_file_path"
|
||||
echo "${passed_option_string}" >> "$phase_file_path"
|
||||
local all_phase_options="$(< "$phase_file_path")"
|
||||
echo -e "${all_phase_options}" | sed '/^$/d' | sort -u > "$phase_file_path"
|
||||
echo "${passed_option_string}" >>"$phase_file_path"
|
||||
local all_phase_options="$(<"$phase_file_path")"
|
||||
echo -e "${all_phase_options}" | sed '/^$/d' | sort -u >"$phase_file_path"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -101,9 +103,9 @@ remove_passed_docker_option() {
|
||||
for phase in "${passed_phases[@]}"; do
|
||||
local phase_file_path="$(get_phase_file_path "$phase")"
|
||||
[[ ! -s "$phase_file_path" ]] || {
|
||||
local all_phase_options="$(< "$phase_file_path")"
|
||||
local all_phase_options="$(<"$phase_file_path")"
|
||||
local all_phase_options=$(echo -e "${all_phase_options}" | sed "s#^${passed_option_string}\$##")
|
||||
echo -e "${all_phase_options}" | sed '/^$/d' | sort -u > "$phase_file_path"
|
||||
echo -e "${all_phase_options}" | sed '/^$/d' | sort -u >"$phase_file_path"
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-docker-options-report() {
|
||||
declare desc="displays a docker options report for one or more apps"
|
||||
@@ -46,7 +47,8 @@ cmd-docker-options-report-single() {
|
||||
dokku_log_verbose "$(printf "%-30s %-25s" "${key^}" "${flag#*: }")"
|
||||
done
|
||||
else
|
||||
local match=false; local value_exists=false
|
||||
local match=false
|
||||
local value_exists=false
|
||||
for flag in "${flag_map[@]}"; do
|
||||
valid_flags="${valid_flags} $(echo "$flag" | cut -d':' -f1)"
|
||||
if [[ "$flag" == "${INFO_FLAG}:"* ]]; then
|
||||
@@ -68,6 +70,6 @@ fn-docker-options() {
|
||||
declare APP="$1" PHASE="$2"
|
||||
local PHASE_FILE="$(fn-get-phase-file-path "$APP" "$PHASE")"
|
||||
if [[ -r "$PHASE_FILE" ]]; then
|
||||
tr '\n' ' ' < "$PHASE_FILE"
|
||||
tr '\n' ' ' <"$PHASE_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/internal-functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-docker-options-report-single "$@"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
@@ -8,7 +9,7 @@ docker_options_add_cmd() {
|
||||
local cmd="docker-options:add"
|
||||
|
||||
verify_app_name "$2" && local APP="$2"
|
||||
read -ra passed_phases <<< "$(get_phases "$3")"
|
||||
read -ra passed_phases <<<"$(get_phases "$3")"
|
||||
shift 3 # everything else passed is the docker option
|
||||
local passed_docker_option="$*"
|
||||
[[ -z "$passed_docker_option" ]] && dokku_log_fail "Please specify docker options to add to the phase"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
@@ -9,7 +10,7 @@ docker_options_main_cmd() {
|
||||
dokku_log_warn "Deprecated: Please use docker-options:report"
|
||||
|
||||
verify_app_name "$2" && local APP="$2"
|
||||
read -ra passed_phases <<< "$(get_phases "$3")"
|
||||
read -ra passed_phases <<<"$(get_phases "$3")"
|
||||
if [[ ! "${passed_phases[@]}" ]]; then
|
||||
display_all_phases_options
|
||||
else
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
|
||||
|
||||
@@ -8,7 +9,7 @@ docker_options_remove_cmd() {
|
||||
local cmd="docker-options:remove"
|
||||
|
||||
verify_app_name "$2" && local APP="$2"
|
||||
read -ra passed_phases <<< "$(get_phases "$3")"
|
||||
read -ra passed_phases <<<"$(get_phases "$3")"
|
||||
shift 3 # everything else passed is the docker option
|
||||
# shellcheck disable=SC2154
|
||||
[[ -z ${passed_docker_option="$@"} ]] && dokku_log_fail "Please specify docker options to remove from the phase"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/docker-options/internal-functions"
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-docker-options-report "$@"
|
||||
|
||||
Reference in New Issue
Block a user