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

Handle heredoc string delimiters #220

Merged
merged 1 commit into from
Nov 18, 2024
Merged

Conversation

brandonpollack23
Copy link
Contributor

@brandonpollack23 brandonpollack23 commented Nov 4, 2024

Maintain HEREDOC (<<EOT style) strings when converting.

Previously our template and string literals only handled strings
delimited by quotes, this will inspect the source and maintain the same
string delim to handle non escaped and multiline strings.

Fixes #219

@brandonpollack23 brandonpollack23 requested a review from a team as a code owner November 4, 2024 18:03
@brandonpollack23 brandonpollack23 marked this pull request as draft November 4, 2024 18:07
@brandonpollack23 brandonpollack23 force-pushed the bpollack/heredoc_strings branch 2 times, most recently from 540fc6d to 7196c92 Compare November 4, 2024 18:18
@brandonpollack23 brandonpollack23 marked this pull request as ready for review November 4, 2024 18:19
@brandonpollack23 brandonpollack23 force-pushed the bpollack/heredoc_strings branch from 7196c92 to ba9dcf2 Compare November 5, 2024 15:53
.vscode/launch.json Outdated Show resolved Hide resolved
pkg/convert/tf.go Outdated Show resolved Hide resolved
pkg/convert/tf.go Outdated Show resolved Hide resolved
pkg/convert/tf.go Outdated Show resolved Hide resolved
pkg/convert/tf.go Outdated Show resolved Hide resolved
pkg/convert/tf.go Outdated Show resolved Hide resolved
@brandonpollack23 brandonpollack23 force-pushed the bpollack/heredoc_strings branch 3 times, most recently from 0026101 to 2dde7dd Compare November 5, 2024 18:42
@brandonpollack23 brandonpollack23 changed the base branch from main to bpollack/template_join_expr November 10, 2024 23:32
pkg/convert/tf.go Show resolved Hide resolved
pkg/convert/tf.go Show resolved Hide resolved
@brandonpollack23 brandonpollack23 force-pushed the bpollack/template_join_expr branch from 7d42c55 to cebc025 Compare November 12, 2024 07:45
@@ -88,7 +88,15 @@
}

output "heredoc" {
value = "This is also a template.\nSo we can output the key again ${aKey}\n"
value = <<END
This is also a template.\nSo we can output the key again ${aKey}\n
Copy link
Member

Choose a reason for hiding this comment

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

Won't this keep \n in the final result now because it's now wrapped in a HEREDOC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great catch, didn't even notice. Fixed now

Base automatically changed from bpollack/template_join_expr to main November 13, 2024 03:03
Previously our template and string literals only handled strings
delimited by quotes, this will inspect the source and maintain the same
string delim to handle non escaped and multiline strings.
This is also a template.
So we can output the key again ${aKey}


Copy link
Member

Choose a reason for hiding this comment

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

Extra whitespace still here

value = <<-END
This is also a template.
So we can output the key again ${aKey}

Copy link
Member

Choose a reason for hiding this comment

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

And here

@brandonpollack23 brandonpollack23 merged commit 0477a5a into main Nov 18, 2024
5 checks passed
@brandonpollack23 brandonpollack23 deleted the bpollack/heredoc_strings branch November 18, 2024 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants