hclq icon indicating copy to clipboard operation
hclq copied to clipboard

Create new values

Open powellchristoph opened this issue 6 years ago • 5 comments

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 avatar May 02 '19 20:05 powellchristoph

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

powellchristoph avatar May 03 '19 19:05 powellchristoph

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

mingfang avatar May 20 '19 13:05 mingfang

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.

mattolenik avatar May 20 '19 19:05 mattolenik

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

timstoop avatar Jul 31 '19 08:07 timstoop

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!

mattolenik avatar Aug 22 '19 18:08 mattolenik