Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packer equivalent of terraform's textencodebase64 function #12982

Closed
josh-martin-1 opened this issue May 16, 2024 · 5 comments · Fixed by #12997
Closed

Packer equivalent of terraform's textencodebase64 function #12982

josh-martin-1 opened this issue May 16, 2024 · 5 comments · Fixed by #12997

Comments

@josh-martin-1
Copy link

josh-martin-1 commented May 16, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

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'.

@lbajolet-hashicorp lbajolet-hashicorp added the stage/thinking Flagged for internal discussions about possible enhancements label May 27, 2024
@lbajolet-hashicorp lbajolet-hashicorp removed the stage/thinking Flagged for internal discussions about possible enhancements label May 27, 2024
@lbajolet-hashicorp
Copy link
Contributor

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!

@josh-martin-1
Copy link
Author

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!

@lbajolet-hashicorp
Copy link
Contributor

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.

@lbajolet-hashicorp
Copy link
Contributor

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!

Copy link

github-actions bot commented Jul 1, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants