Closed vikas027 closed 5 years ago
This is probably going to be rendered unnecessary when we switch to using HCL2 templates later this year, as they allow comments. As a workaround in the meantime, you can either stick to v1.3.5 or you can use jq to remove the "_description" from your packer template as part of your wrapping script.
For example:
jq 'del(._description)' commented_template.json
will print your template without the _description field to stdout.
I'll leave this issue open for now in case a community member wants to work on it, but the HashiCorp maintainers will probably not work on it.
This will be closed in https://github.com/hashicorp/packer/issues/1768
I've added a documentation page that explains how to use jq to strip comments from docs, which will provide you with a workaround until we complete the HCL2 work. you can see it here: https://github.com/hashicorp/packer/pull/7547
I had a case where I had a REALLY long boot_command
array, and I wanted to add comments to it, but with the type == 'object'
I ended up having to wrap my comments within the array to make them objects (otherwise jq
failed to find them), but then when it removed them it left the empty braces causing packer validate
to fail. I extended the command slightly to run another filter and find these empty "objects" and remove them.
jq 'walk(if type == "object" then del(._comment) else . end) | del(.. | select(length == 0))' commented_template.json > clean_template.json ; packer validate clean_template.json && packer build clean_template.json
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Prior to Packer v1.4.0, I was able to use a multiline comment by adding a
_description
in the root level key.Now, in Packer v1.4.0 we need to use
_comment
as shown here.This is fine but it was actually better to use an array rather than a string to store some information of the image along with tracking numbers, etc
Can you please take this as a feature request?