Open jcjones opened 11 months ago
I had no idea Terraform did that, very clever. :grinning: I'll get this into roadmapping, but it also looks like the sort of thing that someone from the community might want to try to pick up so I'll mark it appropriately.
Hi @tgross , Is issue still valid? If yes, I would like to contribute
Thanks
Yes, @PavloGl! You'll find the area of code of interest to be in nomad/structs/diff.go
(with tests in diff_test.go
that you'll want to add to). Thanks!
Thanks for heads up!
Proposal
In Terraform
plan
andapply
diff output, when a string evaluated looks like JSON, the renderer calls a functionrenderStringDiffAsJson
which pretty-prints the output.It would be lovely to have available to Nomad the same capability for understanding diffs of pre-rendered JSON blocks, for when rendering via
jsonencode
is impractical. This would serve to reduce human errors when evaluating the correctness ofplan
outputs.Use-cases
Job specifications which render out JSON can be difficult to evaluate in a
plan
. Take for example this change, which changes a settingmaxConnectionAge
from60s
to30s
in an inline JSON template:Attempted Solutions
It's possible to externally decode the
A => B
syntax into a diff, though complicated by embedded consul template statements. By comparison, Terraform's rendering makes such a diff immediately human-readable.An optimal solution is to not inline JSON, but rather use native HCL structures and the
jsonencode
tool. However, that can be difficult when still relying on runtime lookups or consul templates. So for codebases that are still migrating, JSON rendering would reduce human errors while validatingplan
output.