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

fix(hcl2cdk): Handle multi-line strings better #2812

Merged
merged 4 commits into from
Apr 18, 2023
Merged

Conversation

mutahhir
Copy link
Contributor

@mutahhir mutahhir commented Apr 18, 2023

Related issue

Fixes https://github.com/orgs/hashicorp/projects/207/views/12?pane=issue&itemId=25824022

Description

This is a pretty hacky PR, and I'm not really comfortable with the solution. That being said, I think this does resolve our immediate woes around heredocs.

The problem is as such: By the time the heredoc string comes in for parsing by the expression parser, (I suspect) the hcl2json parser has already converted it into a quote containing newlines. Quote with newlines are not accepted within HCL and thus breaks our expression.

This PR tries to detect newlines within string literals and wraps them back into a heredoc literal, making the expression parseable. As you can see from the PRs, this requires a lot of tweaks to existing logic to ensure it works ok, and even then, I'm not 100% sure this will not be caught off guard on other situations.

Checklist

  • I have updated the PR title to match CDKTF's style guide
  • I have run the linter on my code locally
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if applicable
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works if applicable
  • New and existing unit tests pass locally with my changes

@mutahhir mutahhir merged commit 6faddc0 into main Apr 18, 2023
23 checks passed
@mutahhir mutahhir deleted the fix/multi-line-strings branch April 18, 2023 08:59
@mutahhir mutahhir mentioned this pull request Apr 18, 2023
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants