-
Notifications
You must be signed in to change notification settings - Fork 140
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
Update TFWriter to write files w/hclwrite package #23
Merged
heyealex
merged 5 commits into
GoogleCloudPlatform:develop
from
heyealex:hclwrite-resource-writer
Nov 4, 2021
Merged
Update TFWriter to write files w/hclwrite package #23
heyealex
merged 5 commits into
GoogleCloudPlatform:develop
from
heyealex:hclwrite-resource-writer
Nov 4, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cboneti
reviewed
Nov 4, 2021
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.
Please see my comments
cboneti
approved these changes
Nov 4, 2021
heyealex
force-pushed
the
hclwrite-resource-writer
branch
from
November 4, 2021 22:27
90d232a
to
a9df42a
Compare
In order to handle certian complex data structures and long or multi-line strings, our current approach of converting to YAML flow style strings before writing to HCL files would not longer suffice. This commit implements writing with the [hcl/hclwrite](https://pkg.go.dev/github.com/hashicorp/hcl/v2/hclwrite) library which gives us more control over how HCL is written and enforces style guidelines actively. As part of this conversion, some of the data in the config needs to be converted to cty.Value objects rather than interface{} for handling dynamic typing. This all happens in the writer currently, however at some point it may be better to rebuild the pipeline to work with cty.Value from the start.
Addresses some reviewer feedback: Pulls most functionality into a single function that will be used by all inheriting struct objects (TFWriter, PackerWriter) rather than having empty functions in both to support the interface. Also removes a step from writeTerraformTfvars that updates passthrough variables, as they should not exist there. Added a test to increase coverage once again past 80%.
Merge remote-tracking branch 'upstream/develop' into hclwrite-resource-writer * Updates tests to bring them back up to 80% in the reswriter * Update writeMain to write terraform block with backend * Handle merge conflicts
heyealex
force-pushed
the
hclwrite-resource-writer
branch
from
November 4, 2021 23:20
a9df42a
to
e478c55
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In order to handle certian complex data structures and long or
multi-line strings, our current approach of converting to YAML flow
style strings before writing to HCL files would not longer suffice. This
commit implements writing with the
hcl/hclwrite
library which gives us more control over how HCL is written and enforces
style guidelines actively.
As part of this conversion, some of the data in the config needs to be
converted to cty.Value objects rather than interface{} for handling
dynamic typing. This all happens in the writer currently, however at
some point it may be better to rebuild the pipeline to work with
cty.Value from the start.