Closed josh-martin-1 closed 5 months ago
Hi @josh-martin-1,
PR open now, if you can please consider testing it before we merge it and release a new version of Packer, but hopefully this should work both for encode/decode much like Terraform does.
Thanks for bringing this up!
Hi @lbajolet-hashicorp,
I just tested the changes that you made and it works perfectly for my use case (I only tested textencodebase64 function, didn't test the decode one).
Do you know how long will it take for these changes to make it to an official Packer release? Thanks for the help on this!
Hey @josh-martin-1,
That depends if we can merge it in time, but given 1.11.0 is around the corner, this could be folded into it, so hopefully in a couple days you may be able to use those functions. Otherwise that'll be for a later 1.11.x version, and I cannot say when that will happen unfortunately.
Given the nature of the change though, I'm reasonably confident this can happen for 1.11.0, but we'll keep you updated on that subject.
Hi @josh-martin-1,
FYI we just released Packer 1.11.0 today, which embeds this change. You should be able to update ASAP, but please be advised this version changes interaction with plugins, I suggest you look at the release notes to make sure this doesn't impact your workflows before upgrading in production.
Happy testing!
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.
Community Note
Please search the existing issues for relevant feature requests, and use the reaction feature (https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to add upvotes to pre-existing requests.
Description
Terraform has base64encode (UTF-8) function https://developer.hashicorp.com/terraform/language/functions/base64encode & textencodebase64 (UTF-16LE) function https://developer.hashicorp.com/terraform/language/functions/textencodebase64
Packer only has base64encode (UTF-8) https://developer.hashicorp.com/packer/docs/templates/hcl_templates/functions/encoding/base64encode
Use Case(s)
I would like an equivalent of Terraform's textencodebase64 function in Packer so I can use UTF-16LE/base64 for Windows image creation. I am creating an autounattend.xml file for the Windows image creation, and I am using a template file (autounattend.xml.tpl) to insert text that needs the UTF-16LE/base64 encoding.
Potential configuration
Potential References
https://developer.hashicorp.com/terraform/language/functions/base64encode https://developer.hashicorp.com/terraform/language/functions/textencodebase64 https://developer.hashicorp.com/packer/docs/templates/hcl_templates/functions/encoding/base64encode
https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup-useraccounts-administratorpassword#xml-example This doc from Microsoft has an example of the XML that I am trying to put in the autounattend.xml file. If you take the AdministratorPassword.Value from the XML example and put it into https://www.base64decode.org/ with the source character set set to UTF-16LE, you can see that the example password is "pwAdministratorPassword'.