-
Notifications
You must be signed in to change notification settings - Fork 375
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
Provide richer diff of values changes #1121
Comments
Hi @jcogilvie, can you explain why you defined values with a block of yaml instead of HCL? |
Sure I can. First, the interface for We did try HCL in a We also separately tried to use a bunch of I hope this helps. |
Hi @jcogilvie, Thanks for sharing your use case! However the block of yaml is treated as plain text by terraform so there really isn't any way to break it down further. |
I could be off base here but I think I've seen this happen with lists of strings. I think if there were an option for a singular values file, that might cause terraform to diff the value instead of treating it like a replacement of one string with another. |
I can confirm that a more robust diff behavior is possible if the provider were to expose a single-string variant of I know this from usage of the |
As a intermediate solution i have created a small python script which converts the plan output to make it easier to read Download: https://gist.github.com/Kenterfie/a7ec9e50f17a749b8bb6469f21a6be4f Maybe it will help others as well, as long as no solution exists |
i think a proper diff view is really neccessary here. e.g. kube-prometheus-stack helm chart contains a approx 3000 line values file. changing one line of code outputs 6000 lines of "terraform plan" which is nearly impossible to understand/diff. |
The diff has been an issue for this module for a while. Sometimes it shows the difference and sometimes it just prints the entire yaml twice like @rd-michel is saying. I wrote a little thing like @Kenterfie to diff the ➜ terraform-diff helm_release.onepassword
Generating a diff of 'helm_release.onepassword' in '/var/folders/r1/xx/T/tmp.REIC8M5s'
INFO[0003] Executing hook: create_plugin_directory prefix=[/Users/xxx/asdf/1password]
@@ -23,6 +23,13 @@
- "hosts":
- "1password.xxx.io"
"secretName": "tls-io-xxx-1password"
+ "redis":
+ "master":
+ "resources":
+ "limits":
+ "cpu": 512
+ "requests":
+ "cpu": "250m"
"service":
"type": "ClusterIP" function terraform-diff () {
TEMP=$(mktemp -d)
echo "Generating a diff of '$1' in '$TEMP'"
terraform plan -out=$TEMP/tfplan >/dev/null
terraform show -json $TEMP/tfplan | jq -r '.resource_changes[] | select(.address=="'"$1"'") | .change.before.values | add' > $TEMP/before.txt
terraform show -json $TEMP/tfplan | jq -r '.resource_changes[] | select(.address=="'"$1"'") | .change.after.values | add' > $TEMP/after.txt
diff -u --color=always $TEMP/before.txt $TEMP/after.txt | sed -e '1,2d'
} |
The metadata diffs is present in versions >= 2.10.0. I run a workaround by wrapping the values in sensitive so it doesn't display in the helm resource, then adding a null resource which prints the diffs more nicely. One can use a templatefile for this, or just jsonencode values directly.
|
Hey there. Was looking for that feature and looks like there is no reason to use terraform for helm at all. |
@Punkoivan I would usually prefer that if I didn't need to create additional resources such as buckets or keys, and I didn't need values that I obtain from Terraform. |
@alyssahardy you can try to create just a raw configmap within terraform and then use helm's "lookup" function to get the values. |
Hi. Coming from a helm world, where helm diff works very well, and even comparing with the normal plans available on terraform, having 10s and 100s of lines marked as diff (and in our case, not even being able to see the planned changes) does indeed making working with the kubernetes_helm provider very challenging... Workaround cost time and introduce variability in the processes, which is why it would be preferable that the diff produced more useful results. |
I agree with the benefits of using collections of thx in advance! |
One alternative would be to provide a method to convert a data structure (in our case obtained from |
BTW, this seems to be better in TF 1.8.0. |
nothing changed for me with tf 1.8.0 example:
result: 8372 lines of diff ... minus some terraform description output |
@rd-michel which helm Provider version? Please try pinning down to Version 2.9.0 |
I'm using Terraform 1.8.0 and version 2.13.0 of the provider, and there's definitely been an improvement. It's definitely still a lot of output though. I see a "minus" diff for the entire old set of values and then the entire new set of values with the actual proper diffs within it. It would be great if it just showed the proper diff with some context. |
With new versions of the provider you also get this problem: I mentioned that earlier in this issue: |
you can try enabling manifest from the when it works, it's a big improvement. however, it has provided me with some weird errors that can only be bypassed by turning this off. |
@towolf we always use the latest version of the helm provider (2.13.1 atm). why is it necessary to downgrade to 2.9.0? |
@rd-michel see my previous comment. I refer to the metadata change introduced here: But I don't know exactly what you are complaining about. Too much clutter from metadata or too much context in the actual values diff? |
Ideally, I'd like similar output to |
I have a monitoring terraform module that deploys Loki, Mimir and Grafana. It has to feed in values for the AWS resources it creates (buckets, roles, namespace, secrets). Every time I touch this deployment, no matter how trivial the change, I get a pain in my face as I scroll through a hundred lines of
Known after apply. In other words |
@raffraffraff please try terraform > 1.8.0 and helm provider version 2.9.0. |
September 2024, this is still an issue ❌
Here's a minimal working example for your reference 👇 resource "helm_release" "this" {
name = "external-secrets"
repository = "https://charts.external-secrets.io"
chart = "external-secrets"
version = "0.10.x"
namespace = "external-secrets"
create_namespace = true
set {
name = "crds.createClusterSecretStore"
value = "true"
}
} Apply this stack two times and you will see |
I feel like I'm missing something... How are everyone using the Provider, if it lacks this functionality? |
@GreasyAvocado |
Do you use |
No, I use Additionally, in the v1.16, the helm provider has fixed the metadata issue. Read the following comment: |
The lack of better diff is the main reason why we are avoiding usage of helm, it just feels must more controllable to use the kubernetes provider with manifests. |
@jrluis |
Description
When I have an existing
helm_release
with a set ofvalues[]
, and the values change, often the values are only changing by a few lines. I would like to see a more narrow diff of the selected part of the values that have changed from my last apply, rather than the current view of "old values file replaced by new values file."I'm not sure if this is feasible. But, if I have a long values file, the diff becomes meaningless if it just prints the 100 lines of old file as being replaced by 101 lines of new file, without any indicator of which line has changed.
Take this example diff given a small values file change. Can you immediately tell which line has changed?
Versus a more narrowly scoped change:
I know that 'smarter' diffs are possible in terraform, because I am able to see line by line diffs in helm manifests with
helm_template
if I set them asoutputs
. Maybe this could be achieved by changingvalues
to a map internally with its map key as the index or something, to allow diffs between objects that may not be possible in the current list form.Potential Terraform Configuration
Same as today.
Community Note
The text was updated successfully, but these errors were encountered: