-
Notifications
You must be signed in to change notification settings - Fork 256
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
Handle Remote Modules and Fix HCL Parsing #84
Conversation
I can confirm that this fixes my immediate "broken-ness" using blastradius with TF 0.12.26 |
Awesome to hear! Did you have an open issue for what was broken? If so, can you link it here please? If not, could you elaborate on the "broken-ness" a little please? This way we can gather a little on what this fixes since I included quite a bit into this PR |
Same as some other issues floating around...
|
This is now 2 years stale, closing this |
This does a variety of things that hopefully help out.
Change from using
pyhcl
to usingpython-hcl2
From my understanding terraform, by default, uses hcl2 now. The readme of
pyhcl
mentions that it does not support hcl2 (and therefore modern terraform). Changing to hcl2 seemed to clear up a lot of theunexpected X
errors as well. However, there's still a goofy one when using:
in place of=
such as this:but this is an easy fix to just change the colons to equals
Improve error handling when parsing hcl
I changed up the way the tf files are loaded so that each file is loaded individually rather than creating a big combined one and then saving that to the
Terraform.config
. This way, we can throw an exception that's a little more indicative of where the problem is.For example, if my file for the issue with colons described above is called
myfunc.tf
then when that is loaded, the exception thrown will read:Use
os.path.join
Noticed a comment in
terraform.py
about using path.join instead of the concat by addition so I changed that upHandle remote module
Probably the pièce de résistance of this PR. Added the ability to handle remote modules (at least I think this should handle most cases). Since we require the terraform config to be init'd, we can assume all remote modules are found under .terrform of the topmost dir of the config. From here it's just about getting the right path out of the source description which a simple enough regex does the trick to split things. I tried this on a handful of sources including:
Make viewer usable on parsing failure
Even if the server fails, I personally want to be able to move around the graph it creates even if I don't get the full functionality, so I did just that. When the server fails to parse, the chart is still semi usable and an alert is added to the navbar to indicate that a server exception occurred