-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Improving perception of changes when showing diff #15180
Comments
Hi @danielcompton! Thanks for this feedback, and these suggestions. This is similar to #5179, and there was some discussion about that over there too. A root cause for the sub-optimal output in cases like these is that currently the diff renderer has no awareness of data structures (sets, maps, lists) and instead operates on a flat map of strings, making inferences like this difficult. We've been talking for a little while now about changing the way diffs are represented internally to capture type information and do a structure-oriented rather than a key-by-key diff, which would then give us a better foundation to make enhancements to the output like what you've suggested here. Unfortunately this isn't something we're going to be able to do quickly, since it requires some pretty deep changes to Terraform's core API. It's something we would definitely like to do eventually, though. |
Hi. I'd like to +1 this. Today it's hard to maintain AWS security groups with terraform -- because ingress rules are a list too, and so diffs are impossible to read. |
Hi all! Sorry for the long silence here. The current focus for the Terraform team is to integrate some significant improvements to the configuration language that include a richer type system. Supporting this new type system gives us the information we need to implement better diff rendering as I hinted above, so we're working on prototyping this right now to see if it's something we can reasonably roll out along with the other configuration changes. The following screenshot shows the current output of the prototype with some test data, showing the direction we're currently looking toward: This new format is a pretty different approach than what's in current releases today, mimicking the configuration language syntax to hopefully better describe how Terraform has understood the given values and the proposed changes. The new type system is not yet implemented enough to illustrate this with a real state and config, but the above was produced by real code running against fake values of the same types that the state and config will have once the current work is complete. The current prototype does not align the You can also see here that the diff renderer has access to type information and so it's able to perform "deep" diffs on nested blocks and collection values, showing added/removed values in lists/sets/maps, added/removed lines in multi-line strings, and edits within nested blocks. The This new approach is not fully fleshed out yet since there are some tricky situations that require heuristics, but we think this result is encouraging and plan to investigate further. We're not sure yet whether we'll be able to include this in the initial configuration language improvements release since that's already a pretty significant set of changes, but we will at least lay the groundwork to enable diff rendering like this to be added in a subsequent release. |
This is really promising improvement. Do you have any updates about it? Cheers |
Until this issue is resolved, this small awk utterance works to only show changes.
Would not be printed: Would be printed: Chances are your host already has awk. :) |
@apparentlymart Do you have any update on this? It looks really awesome!! |
Hi @Rowern! The situation hasn't changed from my comment above: we're hoping to be able to include this in the v0.12.0 release, but it's a stretch goal (since that release already has a large scope) and so it may end up arriving in a subsequent release. The decision there will largely depend on how the existing prototype copes with a wide variety of real-world resource types. During prototyping we tested it only with some hard-coded |
I wrote simple ruby script like these. (These codes are pretty bad from the point of rubyist because I wrote in a short time) # In ~/.bashrc etc...
alias terr_colored_diff=$(cat <<EOS
ruby -ne '
input = \$_;
if !input.nil? && input.include?("=>") then
print input.split("\"")[-4] == input.split("\"")[-2] ? "#{input}\e[0m" : "\e[34m#{input}\e[0m"
else
print input + "\e[0m"
end
'
EOS
)
alias terr_delete_no_diff=$(cat <<EOS
ruby -ne '
input = \$_;
if !input.nil? && input.include?("=>") then
print input.split("\"")[-4] == input.split("\"")[-2] ? nil : "\e[34m#{input}\e[0m"
else
print "#{input}\e[0m"
end
'
EOS
)
|
I think |
@davidneudorfer thanks for making me discover landscape! |
Any ETA on when 1.12 will be ready ? Reading the blog post I see "References as first-class values" is still to be announced. The other announcements are really exciting! |
Hi again, all! The new diff renderer changes are now merged in master ready to be included in the forthcoming v0.12.0 release, so I'm going to close this out. You can get a preview of it by trying the alpha2 builds, though please do not use this against any "real" infrastructure yet since there are many known issues with other parts of Terraform still left to fix. |
When I make a change to a large list of values (for example), the plan that Terraform shows is not as helpful as it could be. Here is what I see:
There are three important pieces of information here, but only one is clear:
google_project_services.project
is changing (this is clear from colouring)There is so much going on in the output that it is hard to easily see the relevant information. I have thought of some possible ways the output could be improved:
=>
so it is easier to scan for changesI haven't really considered how default and computed values would be handled here, but it seems highly relevant and important.
Some mockups:
Highlighting changed lines and deemphasising hash
Align =>
Sorting changed attributes to top
Removing unchanged attributes
Relates partly to #15179.
The text was updated successfully, but these errors were encountered: