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
Added templatestring function similar to templatefile #1223
Conversation
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
Reminder for the PR assignee: If this is a user-visible change, please update the changelog as part of the PR. |
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sanskruti-shahu , thanks for submitting this. I've left some feedback in comments.
@Yantrio I'll work upon the changes that you requested. |
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've discussed this with the core team, and we believe that in situations where you pass in either
- A sensitive template
- OR any senstive variables
The resultant templated string should be sensitive.
This is in line with other functionality in OpenTofu.
Would you mind implementing it this way please instead of having it error? Thanks!
Please reach out with any questions you have before beginning any other implementations to avoid re-doing some work!
Signed-off-by: Sanskruti Shahu <76054960+sanskruti-shahu@users.noreply.github.com>
Hey @Yantrio , I've replied to your comments. Could you please check it once? Also, could you review the code changes again to let me know if there are any further changes needed? |
Hi @sanskruti-shahu , we discussed it in one of the conversations that the sensitive value should be propogated throughout instead of erroring. Would you mind implementing this please? I do not see this in the current code. |
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
Hey @Yantrio , I've implemented the changes you mentioned. Could you please review them? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the one tiny tiny nitpick, everything is looking good to me. I've requested that @janosdebugs also looks so that I have a second set of eyes on this, just to be safe.
I've been running things locally and i can confirm the sensitive flag is propagated properly as per the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry to jump in this late into the PR, but there's a large chunk of copy-pasted code and there's no good reason to maintain two copies of the code. Everything else, including the tests is fine, but this should not be merged as is. Please do not copy-paste this much code.
Co-authored-by: James Humphries <James@james-humphries.co.uk> Signed-off-by: Sanskruti Shahu <76054960+sanskruti-shahu@users.noreply.github.com>
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
@janosdebugs , I have implemented the changes you mentioned. Could you please review them? |
Two small changes @sanskruti-shahu requested, but it's looking good ! |
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sanskruti-shahu great job! Tiny nitpick, but I'll approve since these don't change much.
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io>
Signed-off-by: sanskruti-shahu <sanskruti.shahu@harness.io> Signed-off-by: Sanskruti Shahu <76054960+sanskruti-shahu@users.noreply.github.com> Co-authored-by: James Humphries <James@james-humphries.co.uk> Signed-off-by: Ashwin Annamalai <4549937+IgnorantSapient@users.noreply.github.com>
Objective
The objective of this issue is to address a limitation in Terraform, where the
templatefile()
function requires a file to be present on disk, thus restricting the dynamism of template usage. The goal is to introduce a new function namedtemplatestring()
to enable template usage directly from a string, eliminating the need for a file and enhancing flexibility in generating dynamic templates.Changes
MakeTemplateStringFunc()
function insidestring.go
, containing the execution logic for thetemplatestring()
function.render_template.go
, to house the commonrenderTemplate()
function used by bothtemplatestring()
andtemplatefile()
.string_test.go
to validate the implementation of thetemplatestring()
function andrenderTemplate()
function inrender_template_test.go
.templatestring.mdx
, a documentation file outlining the usage of thetemplatestring()
function, to be displayed on the opentofu website.language-nav-data.json
anddescription.go
files to include information about thetemplatestring()
function.CHANGELOG.md
to reflect the addition of thetemplatestring()
function.Resolves #301
Target Release
1.7.0