-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent using reserved names for ns's/partitions #846
Conversation
Some names are reserved by Consul and can't be used for namespaces or partitions. Catching this early before the helm install is a better UX than having the install fail (in the case of partitions) or succeed (in the case of namespaces) and then fail during syncing or injection.
{{- if or (eq "system" $name) (eq "universal" $name) (eq "consul" $name) (eq "operator" $name) (eq "root" $name) }} | ||
{{- fail (cat "The name" $name "set for key" $key "is reserved by Consul for future use." ) }} | ||
{{- end }} | ||
{{- end -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review notes:
- See template docs for how it works
- I'm using
cat
insidefail
to get those values interpolated into the error string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯
{{- if or (eq "system" $name) (eq "universal" $name) (eq "consul" $name) (eq "operator" $name) (eq "root" $name) }} | ||
{{- fail (cat "The name" $name "set for key" $key "is reserved by Consul for future use." ) }} | ||
{{- end }} | ||
{{- end -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAICE!
cd `chart_dir` | ||
local -r name="$1" | ||
run helm template \ | ||
-s templates/connect-inject-deployment.yaml \ | ||
--set 'connectInject.enabled=true' \ | ||
--set "connectInject.consulNamespaces.consulDestinationNamespace=$name" . | ||
|
||
[ "$status" -eq 1 ] | ||
[[ "$output" =~ "The name $name set for key connectInject.consulNamespaces.consulDestinationNamespace is reserved by Consul for future use" ]] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💥
Some names are reserved by Consul and can't be used for namespaces or
partitions. Catching this early before the helm install is a better UX
than having the install fail (in the case of partitions) or succeed (in
the case of namespaces) and then fail during syncing or injection.
This code uses some tricks:
Fixes #593
Checklist: