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

filebase64 function #13195

Open
elliottlawrence opened this issue Oct 29, 2024 · 2 comments · May be fixed by #13202
Open

filebase64 function #13195

elliottlawrence opened this issue Oct 29, 2024 · 2 comments · May be fixed by #13202

Comments

@elliottlawrence
Copy link

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 a filebase64 built-in function, but it doesn't seem like Packer supports it.

For what it's worth, if I try to use the file function on something that isn't valid UTF-8, Packer generates this error, which seems to imply the filebase64 function should exist:

Call to function "file" failed: contents of
*** are not valid UTF-8; use the
filebase64 function to obtain the Base64 encoded contents or the other file
functions (e.g. filemd5, filesha256) to obtain file hashing results instead.

Use Case(s)

Loading a binary file and embedding a base64 encoding of it into a cloud-init config, for example.

Potential configuration

Potential References

@lbajolet-hashicorp
Copy link
Contributor

Hi @elliottlawrence,

Sounds like a good idea indeed, we most likely ported the file function over from Terraform, including the error message, without changing it, hence why it points to a function that doesn't yet exist in Packer.

This should be reasonably easy to port over too, I'll look into this right now, once ported over this will be available in the next version we release.

Thanks for bringing this up!

@lbajolet-hashicorp lbajolet-hashicorp linked a pull request Nov 5, 2024 that will close this issue
@lbajolet-hashicorp
Copy link
Contributor

@elliottlawrence: PR is now open, may I ask you to test it out to be sure it matches your expectations? I have added some tests, but nothing beats real-life experience :)
If it gets approved in the current state, I'll merge it and we'll release it with Packer 1.12.0, which we've scheduled tentatively before end-of-year (probably December).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants