mattolenik / hclq

Command-line processor for HashiCorp config files, like sed for HCL — Terraform, Consul, Nomad, Vault
https://hclq.sh
The Unlicense
252 stars 23 forks source link

Create new values #13

Open powellchristoph opened 5 years ago

powellchristoph commented 5 years ago

It looks like the tool only lets you get/set existing values and not create new ones.

$ cat test.hcl
foo {
    bar = true
}

$ cat test.hcl | hclq set 'foo.baz' 'this is new'
foo {
  bar = true
}

I would really love to be able to do:

$ cat test.hcl | hclq set 'foo.baz' 'this is new'
foo {
  bar = true
  baz = 'this is new'
}
powellchristoph commented 5 years ago

Actually, now that I have started using it. I rather like the existing functionality. Closing as no longer required.

mingfang commented 5 years ago

I need the ability to create new values. Please reopen.

mattolenik commented 5 years ago

Agreed, this would be great! I've started rewriting how values are parsed and set, it doesn't correctly handle all cases. As a consequence of that work, it should be easy to make set add new values as well.

timstoop commented 4 years ago

I'd really like to see this as well! Any update on the progress?

mattolenik commented 4 years ago

I haven't had a chance to try to work this into the current codebase, unfortunately. However, I started working with the HCL2 API, and it simplifies a lot of the things I've been trying to do. Now there's a first-class API for easily manipulating HCL, so I'm starting to rewrite this tool to wrap that functionality with hclq. This rewrite should solve the majority of tricky issues I've had with HCL1.

Unfortunately that does mean dropping HCL1 used by Terraform 0.11, but at this point I don't think it's worth it to continue development with the old language, which is just too hacky.

I'll keep this open until support for HCL2 lands. Stay tuned!