Skip to content
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

Support hcl files #98

Open
josegonzalez opened this issue Feb 26, 2021 · 12 comments
Open

Support hcl files #98

josegonzalez opened this issue Feb 26, 2021 · 12 comments
Labels
enhancement New feature or request

Comments

@josegonzalez
Copy link

Is your feature request related to a problem? Please describe.

HCL is a format commonly used for hashicorp tools. It would be great to add direct support for them in dasel.

Describe the solution you'd like

Support HCL v2.

Describe alternatives you've considered

The alternative is not supporting HCL, which is currently the case :)

Additional context

I would like this so that I can add better support for Nomad in the Dokku PaaS.

@josegonzalez josegonzalez added the enhancement New feature or request label Feb 26, 2021
@TomWright
Copy link
Owner

TomWright commented Feb 27, 2021

I'm always open to supporting new file formats, as long as they play nicely with other implementations.

I will take a look at HCL 2 and get back to you on this soon.

Thank you for your interest in dasel 🙂

@TomWright
Copy link
Owner

Hey @josegonzalez,

This looks like it will be a longer term feature since I'll need to write some logic to parse hcl documents into a generic map[string]interface{}.

Short term it looks like you can use a combination of dasel and hcl2json to read hcl documents with dasel.

I'll leave this issue open so I can work on it when I have the time.

@nikolay
Copy link

nikolay commented Mar 12, 2021

@TomWright I've been using hcl2json with jq but hoped that I can use just one. HCL is widely popular in the DevOps world, so, it would great if it's natively supported.

@josegonzalez
Copy link
Author

Thank you @TomWright for looking into this. I very much appreciate it and realize that development of the functionality may not be forthcoming.

@TomWright
Copy link
Owner

@nikolay I appreciate that and can see the benefit. I'm not saying it's not going to happen, just that I will have to work on it over time rather than a quick change now

@TomWright
Copy link
Owner

It looks like I can import and directly use hcl2json from my code to make that conversion.

This will allow me to add select support relatively easily, but does not (to my knowledge) allow me to convert JSON -> HCL in order for put commands to work.

@josegonzalez
Copy link
Author

Maybe useful for turning a json byte array to hcl? https://github.com/hashicorp/hcl/blob/main/json/public.go#L20

@TomWright
Copy link
Owner

That looks promising.

I also found this repo although it is a little out of data: https://github.com/kvz/json2hcl/blob/master/main.go
I'm not sure if it's for use with hcl v1 or v2.

@josegonzalez
Copy link
Author

That repo is hclv1. Maybe supporting either via a flag works.

@nikolay
Copy link

nikolay commented Mar 12, 2021

By the way, there's a tool like jq just for HCL, but it also only supports v1 (for now): hcql.

@TomWright
Copy link
Owner

TomWright commented Mar 18, 2021

Are we interested in HCL v1, v2 or both?

To save on mass comment replies here maybe add a 👍 for v1 and a 👎 for v2.

@TomWright
Copy link
Owner

Thanks for all the feedback here.

I am currently reworking the encoding/decoding of all supported formats here: #289

Once that is done I will use have a crack at implementing parsers for HCL V2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants