hcledit
hcledit copied to clipboard
Inline comment make parser stop
Hi!
I'm trying to use hcledit to parse module input variables of type object(), with inline comments. Looking like this:
variable "test" {
type = object({
foo = string # The foo variable is used to control the foo'nes
bar = number # The number of foos
})
}
But cat variables.tf | hcledit attribute get "variable.test.type" will only output the first key in the object:
object({
foo = string
If I remove the two inline comments, the output of hcledit is correct:
object({
foo = string
bar = number
})
We are using these comments to document complex variables and need to have them inline.
@bjornrog Thank you for reporting this! It looks a bug caused by a hack here due to the current limitation of the hcl library.
https://github.com/minamijoyo/hcledit/blob/397e5f46bda35b45501b36b841afd8b9d683a0f4/editor/sink_attribute_get.go#L184-L205
I think it's hard to resolve the root cause, but probably possible adding a new flag to include or exclude an inline comment. Does it make sense as a workaround for you?
Additionally the // character string also breaks the parser.
Fixed in v0.2.8 🚀