-
Notifications
You must be signed in to change notification settings - Fork 60
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
Dumping HCL #4
Comments
I suspect HCL dumping will be a bit problematic, as it doesn't always have a non-ambiguous mapping between dictionaries / hcl (see #1). I have no plans to implement dumping for HCL, but would welcome the contribution. If one were to go about doing this, for testing I would probably modify test_decoder.py such that you round-trip to/from json/hcl to/from hcl. That should allow you to get decent coverage on many of the language features. It would probably be good to modify hcltool such that it could take in json or hcl and output hcl or json. |
Thanks for the response. I actually never realized that there is such ambiguity in HCL itself. I think I'd rather wait for #1 get sorted out before implementing this. I'll keep an eye on it and on related issues and get back to this when I'm sure I know how to do this properly :) |
Any updates on this ? |
I'm open to pull requests, but won't be developing the functionality myself. |
It looks like So that's really just converting/dumping to JSON, not a true HCL dump. |
Yes, as the documentation says. Pull requests still welcome. :) |
Would it be ok, to create a pull request with work-in-progress code? The idea is to have a base-class which holds a class Foo(HclBase):
NAME = "Foo"
def __init__(self):
self._hcl_label = 'foo_label'
self.string = 'Some String'
self.num = 128
self.bool = True
class Bar(HclBase):
NAME = "Bar"
def __init__(self):
self._hcl_label = 'bar_label'
self.foo = Foo()
self.arr = ['I', 'am', 'a', 'pirate', '!']
self.map = {'test': 1, 'set': 2, 'tes': 3} would be dumped to: Bar "bar_label" {
arr = ["I", "am", "a", "pirate", "!"]
Foo "foo_label" {
bool = true
num = 128
string = "Some String"
}
map = {
test = 1
set = 2
tes = 3
}
} |
@derfalx isn't the point to take the output of |
Hmm, yeah this is more kind of a writer/encoder than of a dump. |
I use your module to patch terraform HCL files, but unfortunately it lacks the "dump back to HCL file" functionality. It would be great if it will be implemented one day. |
Hi, I'm working on a library called anymarkup [1] and got a request from one of its users to provide support for HCL [2]. I think this project is the only Python library that deals with HCL, but it can't dump it, just load it.
Do you have any plans for implementing HCL dumping? If not, I'd like to work on that and would appreciate any pointers you might have - like if you have an idea how this should work, a design already thought through in your head or something else. I'd like to prevent implementing something that you wouldn't like :)
[1] https://github.com/bkabrda/anymarkup
[2] bkabrda/anymarkup#6
The text was updated successfully, but these errors were encountered: