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

Produce unquoted YAML from Dhall #2497

Open
vmchale opened this issue Mar 28, 2023 · 4 comments
Open

Produce unquoted YAML from Dhall #2497

vmchale opened this issue Mar 28, 2023 · 4 comments

Comments

@vmchale
Copy link
Collaborator

vmchale commented Mar 28, 2023

Hello,

I'm trying to produce templated YAML from Dhall; the desired output is

kind: Deployment
spec:
  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}

Basically I would want the output string to be unquoted so that the templating engine can pick up "/configmap.yaml"

(I came from a question here, as far as I can tell there isn't a canonical solution!)

Thanks!

@Gabriella439
Copy link
Collaborator

yeah, there still isn't a way to do this

i'd be open to a pr that added support for this; the main open question is whether the quoting should be disabled globally in the generated YAML or just for a specific field (and if so, then how)

@m4dc4p
Copy link

m4dc4p commented Oct 25, 2023

Where does dhall-to-yaml generate quoted strings today? I'd like to dig into the code a little as I have this same issue.

@Gabriella439
Copy link
Collaborator

So there is the dhall-to-yaml executable (which is provided by the dhall-json package for reasons) and the dhall-to-yaml-ng executable (which is provided by the dhall-yaml package). The dhall-yaml README provides a brief explanation of why there are two such executables.

For the dhall-to-yaml executable, you can find the relevant logic for that here:

https://github.com/dhall-lang/dhall-haskell/blob/main/dhall-json/src/Dhall/JSON/Yaml.hs

For the dhall-to-yaml executable, you can find the relevant logic for that here:

https://github.com/dhall-lang/dhall-haskell/blob/main/dhall-yaml/src/Dhall/Yaml.hs

@winitzki
Copy link
Collaborator

I would say that unquoted strings are special options that should be supported by adding those options to a Dhall data type. Right now there is already a JSON data type in the Dhall prelude. That data type can be enhanced to include an option for unquoted strings. When converting the JSON data type to YAML, that option may be taken into account.

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