Thanks for the suggestions, I am now using a shell script to preprocess the 
file like this:

jsmin <$1 | jq '{_generated:"this file was generated, please edit the 
source file \"'$1'\" instead"}+.' >`basename $1 .json`_nocomments.json

that works quite well.

On Saturday, July 15, 2017 at 10:43:09 PM UTC+2, Gabo Kete wrote:
>
> Hi Alexander
>
> I hope I have understood correctly your question... I do have in my JSON 
> files one line of comments right before I start the definition of my 
> variables.. this is the way I have added them
>
> {
>   *"_comment": "This si a centos7-x64 Machine for VmWare ESXi 6.0", <=== 
> My comments*
>   "variables": {
>     "nameVm": "centos-7.1-vmware_DevOPS",
>     "ks_file": "simple-ks-integrado-CIS-BitbyBit.ks",
>     "ks_server": "192.168.1.150",
>     "ks_path": "centos7.1511_x64/ks/",
>     "vmware_host": "192.168.1.250",
>     "http_dir": "/packer"
> }
>
> Basically is to add the "_comment" style element in the JSON file at the 
> very beginning. I do use this to describe what the is the purpose of the 
> whole JSON file
>
> The other way I have found myself using comments and not affect the JSON 
> file, is using JSMIN <http://www.crockford.com/javascript/jsmin.html> 
>
> Hope this helps
>
>
> On Sunday, July 16, 2017 at 12:21:25 AM UTC+12, Alexander Lehmann wrote:
>>
>> As Packer is using json for the config, I would like to run a 
>> preprocessor before running packer to strip Javascript comments from the 
>> json file.
>>
>> I have found a nodejs tool for that called strip-json-comments-cli which 
>> works ok, but since that requires npm install, it seems like kind of 
>> complicated to provision e.g. in a CI environment just for the single 
>> script.
>>
>> On the other hand I could add the stripped file in the git repo so that 
>> as long as there are no changes in the source file, the tool is not needed 
>> (which would solve the CI question).
>>
>> Can anyone suggest other tools (e.g. in go) or are you using another 
>> procedure to get comment support for the config file?
>>
>>
>> Thanks, Alexander
>>
>>
>>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/57f294e6-dfba-46de-9195-740e1a2379fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to