This is hard to fix in a non breaking way and I think it will nut be fixed
in the short term. Hopefully by the end of the year Packer uses HCL2 and
that will fix this problem.

This is very easily handled with jq.
$ echo '{ "a": "", "b": "X" }' | jq '.a=[ 1, 2, 3 ]'
{
  "a": [
    1,
    2,
    3
  ],
  "b": "X"
}


On Thu, Mar 14, 2019 at 5:45 PM Todd Foley <[email protected]> wrote:

> Okay, i'll create a single template for each build; sounds like we need to
> write a tool that generates the template from a script to get around this.
> Any chance for this to be a feature request the team might take up?
>
> On Wednesday, March 13, 2019 at 9:48:51 PM UTC-7, Rickard von Essen wrote:
>>
>> You can't.
>>
>> On Thu, Mar 14, 2019, 00:39 Todd Foley <[email protected]> wrote:
>>
>>> How do you escape a comma in a user variable?
>>>
>>> This breaks the functionality of the build. this example is based off
>>> the defined example:
>>> https://packer.io/docs/builders/docker.html#run_command
>>> The only difference is this is going through a user variable, which
>>> breaks because the parsing has no way to escape the comma that has to be
>>> ignored.
>>>
>>> {
>>>   "variables": {
>>>     "changes": "CMD [\"nginx\", \"-g\", \"daemon off;\"]"
>>>   },
>>>
>>>   "builders": [
>>>     {
>>>       "type": "docker",
>>>       "image": "ubuntu:16.04",
>>>       "run_command": ["-d", "{{.Image}}"],
>>>       "changes":      "{{ user `changes`}}",
>>>       "commit": true
>>>     }
>>>   ],
>>>   "post-processors": [
>>>     [
>>>       {
>>>         "type": "docker-tag",
>>>         "repository": "my/ubuntu",
>>>         "tag": "16.04"
>>>       }
>>>     ]
>>>   ]
>>> }
>>>
>>> --
>>> 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/92180783-e0be-4324-86be-fcee97018201%40googlegroups.com
>>> <https://groups.google.com/d/msgid/packer-tool/92180783-e0be-4324-86be-fcee97018201%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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/48be24b2-ac2f-42fc-bd1e-bf225cdbac41%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/48be24b2-ac2f-42fc-bd1e-bf225cdbac41%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALz9Rt81qjnsU7Wwm_3-Cmi_LTqpRHq3-9mFNxXupOfU%2BASQNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to