Skip to content

[kots]: escape golang template variables for Helm resources #8892

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

Merged
merged 1 commit into from
Mar 22, 2022

Conversation

mrsimonemms
Copy link
Contributor

@mrsimonemms mrsimonemms commented Mar 18, 2022

This is quite annoying it got missed as (I thought) I had tested this deployment fully. Huge thanks to @geropl for helping me debug this one 🙏🏻

Description

Helm parses Golang template variables when rendering the Kubernetes objects. For the ws-manager config (and potentially others), this breaks as this includes Golang template variables which is interpolated at runtime.

Helm allows for escaping of Golang template variables if wrapped in {{`x`}}. The sed command searches for any line containing {{ and escapes the whole line - because we use backticks and it's (currently) only in a JSON configmap, this escapes everything adequately.

How to test

Deploy via KOTS and run a workspace

Release Notes

[kots]: escape golang template variables for Helm resources

Documentation

Helm parses Golang template variables when rendering the Kubernetes
objects. For the ws-manager config (and potentially others), this
breaks as this includes Golang template variables which is interpolated
at runtime.

Helm allows for escaping of Golang template variables if wrapped in
"{{``}}". The sed command searches for any line containing "{{" and
escapes it.
@mrsimonemms mrsimonemms marked this pull request as ready for review March 18, 2022 20:57
@mrsimonemms mrsimonemms requested a review from a team March 18, 2022 20:57
@github-actions github-actions bot added the team: delivery Issue belongs to the self-hosted team label Mar 18, 2022
Copy link
Contributor

@Pothulapati Pothulapati left a comment

Choose a reason for hiding this comment

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

LGTM! Also, Good Find!

Was able to find that, the ws-manager requires the following templates in its config

        "urlTemplate": "https://{{ .Prefix }}.ws.tarun.self-hosted.com",
        "portUrlTemplate": "https://{{ .WorkspacePort }}-{{ .Prefix }}.ws.tarun.self-hosted.com",

which is then replaced by the following after the sed command:

{{`        "urlTemplate": "https://{{ .Prefix }}.ws.tarun.self-hosted.com",`}}
{{`        "portUrlTemplate": "https://{{ .WorkspacePort }}-{{ .Prefix }}.ws.tarun.self-hosted.com",`}}

@roboquat roboquat merged commit 717ceb0 into main Mar 22, 2022
@roboquat roboquat deleted the sje/kots-helm-escape branch March 22, 2022 05:46
@mrsimonemms
Copy link
Contributor Author

mrsimonemms commented Mar 22, 2022

@Pothulapati correct analysis 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note size/XS team: delivery Issue belongs to the self-hosted team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants