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

Base64 encode Text #1092

Open
timspeetjens opened this issue Oct 28, 2020 · 4 comments
Open

Base64 encode Text #1092

timspeetjens opened this issue Oct 28, 2020 · 4 comments

Comments

@timspeetjens
Copy link

Is there a possibility to base64 encode Text? If not, would you consider adding something like Text/base64encode?

While a lot can be said about Kubernetes Secrets, this would improve the process of creating them using dhall-kubernetes.

@Gabriella439
Copy link
Contributor

I'd be fine with adding some sort of base-64 encoding, but my intuition here is that it would first need to be preceded by language support for some sort of Bytes type

The reason why is that I tend to view base-64 encoding of Text as the composition of two separate operations:

  • Text/encodeUTF8 : Text → Bytes
  • Bytes/encodeBase64 : Bytes → Text

… so that users can select an encoding other than UTF8 when deciding how to base-64 encode Text.

@philandstuff
Copy link
Collaborator

Yeah i agree with @Gabriel439 for similar reasons: the point of base64 is to represent arbitrary binary data as text, but right now we don’t have a way to represent arbitrary binary data, only text, and text can be represented as Text without the need for base64.

@timspeetjens
Copy link
Author

@Gabriel439 what you propose makes sense, indeed.

This would also open up possibilities to add binary files in ConfigMaps in dhall-kubernetes.

When binary files must be added, it could be accomplished like

let asset = ./truststore.jks as Bytes

let assetB64 = Bytes/encodeBase64 asset

in  k.ConfigMap::{
      ...
      , binaryData = Some ( toMap { `truststore.jks` = assetB64 )
}

@PierreR
Copy link

PierreR commented Nov 10, 2020

For reference, Cue supports bytes that are converted to base64 when emitting json: https://cue.googlesource.com/cue/+/55102471f0fc4bcd261e87645461093f7527b4e5/doc/tutorial/basics/bytes.md

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

No branches or pull requests

4 participants