mirror of
https://github.com/dokku/dokku.git
synced 2026-07-11 13:01:51 +02:00
refactor: remove unused bash report helper functions
With every bash :report subcommand now ported to golang, the shared fn-report-parse-args, fn-report-emit-json, fn-report-filter-global and fn-report-validate-format helpers are no longer referenced and are removed.
This commit is contained in:
@@ -1028,62 +1028,3 @@ fn-registry-docker-config-dir() {
|
||||
echo "$config_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
fn-report-parse-args() {
|
||||
declare desc="strips --format and --global flags from a report invocation, populating REPORT_FORMAT, REPORT_IS_GLOBAL, REPORT_ARGS"
|
||||
REPORT_FORMAT="stdout"
|
||||
REPORT_IS_GLOBAL="false"
|
||||
REPORT_ARGS=()
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--format)
|
||||
REPORT_FORMAT="$2"
|
||||
shift 2
|
||||
;;
|
||||
--global)
|
||||
REPORT_IS_GLOBAL="true"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
REPORT_ARGS+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
fn-report-emit-json() {
|
||||
declare desc="serializes a flag_map array (passed by name) as a JSON object, stripping the --<prefix>- prefix from each key"
|
||||
declare flag_map_name="$1" prefix="$2"
|
||||
local -n flag_map_ref="$flag_map_name"
|
||||
local json_output="{}"
|
||||
for flag in "${flag_map_ref[@]}"; do
|
||||
local key value
|
||||
key="$(echo "$flag" | cut -d':' -f1 | sed "s/^--${prefix}-//")"
|
||||
value="$(echo "$flag" | cut -d':' -f2- | sed 's/^ //')"
|
||||
json_output="$(echo "$json_output" | jq -c --arg key "$key" --arg value "$value" '. + {($key): $value}')"
|
||||
done
|
||||
echo "$json_output"
|
||||
}
|
||||
|
||||
fn-report-filter-global() {
|
||||
declare desc="filters a flag_map array (passed by name) in place, keeping only entries with -global- in their flag name"
|
||||
declare flag_map_name="$1"
|
||||
local -n flag_map_ref="$flag_map_name"
|
||||
local filtered=()
|
||||
for flag in "${flag_map_ref[@]}"; do
|
||||
local key="$(echo "$flag" | cut -d':' -f1)"
|
||||
if [[ "$key" == *"-global-"* ]]; then
|
||||
filtered+=("$flag")
|
||||
fi
|
||||
done
|
||||
flag_map_ref=("${filtered[@]}")
|
||||
}
|
||||
|
||||
fn-report-validate-format() {
|
||||
declare desc="rejects --format json when an info flag is also specified"
|
||||
declare FORMAT="$1" INFO_FLAG="$2"
|
||||
if [[ "$FORMAT" != "stdout" ]] && [[ -n "$INFO_FLAG" ]]; then
|
||||
dokku_log_fail "--format flag cannot be specified when specifying an info flag"
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user