Skip to content
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

Update external URLs if cattle values are provided #1097

Merged
merged 2 commits into from
Apr 9, 2021

Conversation

aiyengar2
Copy link
Contributor

@aiyengar2 aiyengar2 commented Apr 7, 2021

Sets the externalURL to the rancher proxy if and only if .Values.global.cattle.url and .Values.global.cattle.clusterId are set.

While these will be set magically by default in Rancher 2.5.8 onwards by the dashboard UI, this solution doesn't prevent a user from manually setting these fields to be able to use this in Rancher 2.5.7 or before.

@aiyengar2 aiyengar2 force-pushed the update_external_urls branch 2 times, most recently from 04e7707 to 650e08c Compare April 7, 2021 23:35
externalUrl: "{{ tpl .Values.alertmanager.alertmanagerSpec.externalUrl . }}"
{{- else if and .Values.alertmanager.ingress.enabled .Values.alertmanager.ingress.hosts }}
externalUrl: "http://{{ tpl (index .Values.alertmanager.ingress.hosts 0) . }}{{ .Values.alertmanager.alertmanagerSpec.routePrefix }}"
+{{- else if not (or (kindIs "invalid" .Values.global.cattle.url) (kindIs "invalid" .Values.global.cattle.clusterId)) }}
Copy link
Contributor Author

@aiyengar2 aiyengar2 Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kindIs "invalid" {field} is a nice little hack that allows us to not have to check .Values.global and .Values.global.cattle before looking at this field. If .Values.global or .Values.global.cattle do not exist, these statements will return true (since it is invalid). It will also return true if they are empty strings.

Credit goes to Masterminds/sprig#53 (comment).

Copy link
Contributor

@brendarearden brendarearden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aiyengar2 aiyengar2 merged commit 089a87e into rancher:dev-v2.5-source Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants