fix: add validation for runner host and type combinations in configuration wizard
This commit is contained in:
@@ -77,6 +77,15 @@ validate_runner_host() {
|
|||||||
[[ "$1" == "unraid" || "$1" == "fedora" || "$1" == "local" || "$1" == "custom" ]]
|
[[ "$1" == "unraid" || "$1" == "fedora" || "$1" == "local" || "$1" == "custom" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validate_runner_host_type_combo() {
|
||||||
|
local host="$1" runner_type="$2"
|
||||||
|
if [[ "$host" == "local" ]]; then
|
||||||
|
[[ "$runner_type" == "native" ]]
|
||||||
|
else
|
||||||
|
[[ "$runner_type" == "docker" ]]
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
validate_runner_path() {
|
validate_runner_path() {
|
||||||
# shellcheck disable=SC2088 # tilde intentionally stored as literal string
|
# shellcheck disable=SC2088 # tilde intentionally stored as literal string
|
||||||
[[ "$1" == /* || "$1" == "~/"* || "$1" == "~" ]]
|
[[ "$1" == /* || "$1" == "~/"* || "$1" == "~" ]]
|
||||||
@@ -379,7 +388,7 @@ for ((i = 0; i < runner_count; i++)); do
|
|||||||
save_runner_field "$r_name" "ssh_user" "$PROMPT_RESULT"
|
save_runner_field "$r_name" "ssh_user" "$PROMPT_RESULT"
|
||||||
prompt_field "ssh_port" "SSH port" "port" "${ex_ssh_port:-22}"
|
prompt_field "ssh_port" "SSH port" "port" "${ex_ssh_port:-22}"
|
||||||
save_runner_field "$r_name" "ssh_port" "$PROMPT_RESULT"
|
save_runner_field "$r_name" "ssh_port" "$PROMPT_RESULT"
|
||||||
prompt_field "ssh_key" "path to SSH key (empty = ssh-agent)" "optional_path" "$ex_ssh_key" "true"
|
prompt_field "ssh_key" "path to SSH key (empty = use default keys)" "optional_path" "$ex_ssh_key" "true"
|
||||||
save_runner_field "$r_name" "ssh_key" "$PROMPT_RESULT"
|
save_runner_field "$r_name" "ssh_key" "$PROMPT_RESULT"
|
||||||
# Adjust total prompts (added 4 custom fields, but we already allocated 10)
|
# Adjust total prompts (added 4 custom fields, but we already allocated 10)
|
||||||
;;
|
;;
|
||||||
@@ -393,8 +402,23 @@ for ((i = 0; i < runner_count; i++)); do
|
|||||||
if [[ -z "$type_default" ]]; then
|
if [[ -z "$type_default" ]]; then
|
||||||
if [[ "$r_host" == "local" ]]; then type_default="native"; else type_default="docker"; fi
|
if [[ "$r_host" == "local" ]]; then type_default="native"; else type_default="docker"; fi
|
||||||
fi
|
fi
|
||||||
prompt_field "type" "docker (Linux) or native (macOS)" "runner_type" "$type_default"
|
if [[ "$r_host" == "local" ]]; then
|
||||||
|
type_hint="native only for host=local"
|
||||||
|
else
|
||||||
|
type_hint="docker only for host=unraid/fedora/custom"
|
||||||
|
fi
|
||||||
|
prompt_field "type" "$type_hint" "runner_type" "$type_default"
|
||||||
r_type="$PROMPT_RESULT"
|
r_type="$PROMPT_RESULT"
|
||||||
|
while ! validate_runner_host_type_combo "$r_host" "$r_type"; do
|
||||||
|
if [[ "$r_host" == "local" ]]; then
|
||||||
|
printf '%b Invalid combo: host=local requires type=native%b\n' "$C_RED" "$C_RESET"
|
||||||
|
prompt_field "type" "native only for host=local" "runner_type" "native"
|
||||||
|
else
|
||||||
|
printf '%b Invalid combo: host=%s requires type=docker%b\n' "$C_RED" "$r_host" "$C_RESET"
|
||||||
|
prompt_field "type" "docker only for host=unraid/fedora/custom" "runner_type" "docker"
|
||||||
|
fi
|
||||||
|
r_type="$PROMPT_RESULT"
|
||||||
|
done
|
||||||
save_runner_field "$r_name" "type" "$r_type"
|
save_runner_field "$r_name" "type" "$r_type"
|
||||||
|
|
||||||
# --- data_path ---
|
# --- data_path ---
|
||||||
|
|||||||
Reference in New Issue
Block a user