install-agent-k8s.sh gives a very cryptic error when `sysdig_instance_name` has spaces in it
Opened this issue · 0 comments
By sheer coincidence my script declared SYSDIG_INSTANCE_NAME and it has spaces in it. For example - My Sysdig Instance
. I never passed any value to sysdig_instance_name
But the script used it anyway :) https://github.com/draios/sysdig-cloud-scripts/blob/master/agent_deploy/IBMCloud-Kubernetes-Service/install-agent-k8s.sh#L422
https://github.com/draios/sysdig-cloud-scripts/blob/master/agent_deploy/IBMCloud-Kubernetes-Service/install-agent-k8s.sh#L284 choked with error as
sed: -e expression #1, char 45: unterminated
s' command`
Since sysdig_instance_name
is expected to be used as K8s labels, it can't have any spaces..
A valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
We should use the regex to validate the value to avoid throwing error at later stages and make it clear in documentation
If we don't want to keep up with K8s changes, we should simply let user pass whatever he wishes to and get that correctly sed
'ed, actual error about spaces etc will eventually be thrown by K8s API