Commit 12235fe7 authored by Josh McSavaney's avatar Josh McSavaney

Perform basic validation on K3S_URL in install.sh

This allows us to fail quickly if we're handed a schemeless or plain HTTP URI, rather than having the agent barf when the systemd unit starts. For an operator, this makes for a cleaner error up front and clear messaging for how to fix the situation. Signed-off-by: 's avatarJosh McSavaney <mcsaucy@csh.rit.edu>
parent dd25c2b7
...@@ -153,6 +153,9 @@ setup_env() { ...@@ -153,6 +153,9 @@ setup_env() {
if [ -z "${K3S_TOKEN}" ] && [ -z "${K3S_CLUSTER_SECRET}" ]; then if [ -z "${K3S_TOKEN}" ] && [ -z "${K3S_CLUSTER_SECRET}" ]; then
fatal "Defaulted k3s exec command to 'agent' because K3S_URL is defined, but K3S_TOKEN or K3S_CLUSTER_SECRET is not defined." fatal "Defaulted k3s exec command to 'agent' because K3S_URL is defined, but K3S_TOKEN or K3S_CLUSTER_SECRET is not defined."
fi fi
if ! echo "${K3S_URL}" | grep -q "^https://"; then
fatal "Only https:// URLs are supported for K3S_URL (have ${K3S_URL})"
fi
CMD_K3S=agent CMD_K3S=agent
fi fi
;; ;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment