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

Update Terraform repl package to bring in better formatting #14

Merged
merged 3 commits into from
Mar 18, 2021

Conversation

jrhouston
Copy link
Owner

@jrhouston jrhouston commented Mar 17, 2021

The repl package in Terraform core was updated to include heredoc formatting
for multiline strings.

The interface for the terraform/repl package changed to use cty.Value
rather than map[string]interface{} so I had to bring in cty as a dependency
and update the code that munges the manifest after it has been decoded to use it.

Closes #13

Multi-line support looks like this:

Screen Shot 2021-03-17 at 8 06 39 PM

The repl package in Terraform core was updated to include heredoc formatting
for multiline strings. The interface for this package changed to use cty.Value
rather than map[string]interface{} so I had to bring in cty as a dependency
and update the code that munges the manifest after it has been decoded to use it.
var serverSideMetadataFields = []string{
// ignoreMetadata is the list of metadata fields to strip
// when --strip is supplied
var ignoreMetadata = []string{
Copy link
Collaborator

Choose a reason for hiding this comment

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

managedFields should also be dropped. They usually appear on resources extracted off a running cluster with 'kubectl get` and are technically a read-only field from the POV of the client.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah it is on the list it's just hidden by this diff 😄

Copy link
Collaborator

Choose a reason for hiding this comment

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

🤦


// stripServerSideFields removes fields that have been added on the
// server side after the resource was created such as the status field
func stripServerSideFields(doc cty.Value) cty.Value {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not for this PR, but this function seems a prime candidate for some unit testing. Looks nicely isolated with (almost) no dependencies.

@jrhouston jrhouston merged commit fef3896 into main Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option for multiline strings
2 participants