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

feat(templating): adds encodeBase64 handlebars helper #26197

Merged
merged 7 commits into from
Dec 11, 2023
Merged

feat(templating): adds encodeBase64 handlebars helper #26197

merged 7 commits into from
Dec 11, 2023

Conversation

moltar
Copy link
Contributor

@moltar moltar commented Dec 8, 2023

Changes

Adds a encodeBase64 handlebars helper that encodes a string to Base64.

Context

When using template variables with strings that may contain special characters, it makes it more
difficult to use with commands.

Consider this example:

"postUpgradeTasks": [
  "echo \"{{body}}\" > file.md"
]

The value of the body variable contains the full changelog, which may contain anything.

Renovate will replace the variable, before the command runs, and thus it will result in a command:

echo "This is a changelog" > file.md

But if the body variable contains a double quote, the command will fail:

echo "This is "a" changelog" > file.md

By encoding the values in Base64, we can avoid this issue:

"postUpgradeTasks": [
  "echo \"{{encodeBase64 body}}\" | base64 -d > file.md"
]

Related discussion: #26175

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@moltar moltar marked this pull request as ready for review December 8, 2023 09:55
rarkins
rarkins previously approved these changes Dec 8, 2023
@rarkins rarkins changed the title feat: adds encodeBase64 handlebars helper feat(templating): adds encodeBase64 handlebars helper Dec 8, 2023
@rarkins rarkins requested a review from viceice December 8, 2023 10:55
secustor
secustor previously approved these changes Dec 8, 2023
lib/util/template/index.ts Outdated Show resolved Hide resolved
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
@rarkins rarkins dismissed stale reviews from secustor and themself via cbf34e2 December 8, 2023 13:28
@rarkins rarkins requested a review from viceice December 8, 2023 13:30
viceice
viceice previously approved these changes Dec 8, 2023
@moltar
Copy link
Contributor Author

moltar commented Dec 10, 2023

Added extra tests for nullish coalescing to fix coverage.

@viceice viceice added this pull request to the merge queue Dec 11, 2023
Merged via the queue into renovatebot:main with commit 2438616 Dec 11, 2023
36 checks passed
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 37.90.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@moltar moltar deleted the feat/handlebars-helper-encode-base64 branch December 11, 2023 18:07
hersentino pushed a commit to hiventive/renovate that referenced this pull request Jan 9, 2024
)

Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants