Open TristanCacqueray opened 4 years ago
Hi @TristanCacqueray,
What to quote, when, and how, is very much a balancing act. We've gone back and forth many times (including on whether to quote single/simple words), and what we have now is the combination that seems the least upsetting.
I think going back to quoting single words to accommodate the checksum example would not be worth it, as it would make common outputs like this very hard to read:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: foo
name: "{{ .Release.Name }}-deployment"
spec:
replicas: 1
selector:
matchLabels:
app: foo
template:
metadata:
labels:
app: foo
name: "{{ .Release.Name }}-pod"
spec:
containers:
- command:
- /data/bin/foo
- "--port=7654"
image: ubuntu:latest
name: "{{ .Release.Name }}-container"
ports:
- containerPort: 7654
script: |
#!/bin/bash
echo hello world
volumeMounts:
- mountPath: /data/mount1
name: "{{ .Release.Name }}-volume-mount1"
- mountPath: /data/mount2
name: "{{ .Release.Name }}-volume-mount2"
Single words are specifically not quoted to make this kind of output look familiar.
The second example of an IP vs. IP/CIDR is an oddity, yeah. It's because we know it's safe to single-quote the first string, whereas the latter has symbols and we fall back to Aeson's encoding which is double-quoted. I would be happy to accept a PR that makes CIDR strings single-quoted so that those two are at least consistent.
Might I also suggest using encodeQuoted
(quoted
in https://hackage.haskell.org/package/dhall-json-1.7.0/docs/Dhall-JSON-Yaml.html#t:Options or --quoted
in dhall-to-yaml
)? That should make the quoting quite consistent.
I agree the current status-quo is the least upsetting. I'll have a look to add a special case for IP/CIDR.
Thank you for the detailed feedback.
The context for this is https://github.com/dhall-lang/dhall-haskell/issues/1894 where I am wondering if a string value that contains a single word could always be quoted. This would enable a nicer output when the values are checksum, for example:
Instead of the current output:
Another odd behavior is regarding single vs double quote on this output: