cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.03k stars 287 forks source link

encoding: ini support #2689

Open uhthomas opened 10 months ago

uhthomas commented 10 months ago

Is your feature request related to a problem? Please describe.

Some applications, like Grafana, use ini files for configuration.

Describe the solution you'd like

It would be nice to have a new encoding/ini package for marshalling cue to ini.

Describe alternatives you've considered

Additional context

The Grafana configuration in a Kubernetes config map is just plain text. The configuration could be represented with cue and encoded to ini.

https://github.com/uhthomas/automata/blob/92de44958bb7c7ac91ad693a09febffeeebd021c/k8s/unwind/grafana/config_map_list.cue#L43-L68

mvdan commented 10 months ago

Not a duplicate of https://github.com/cue-lang/cue/issues/1621 at all, but worth noting that they are both similar plaintext key-value config formats.

mvdan commented 10 months ago

Also worth noting that with @myitcv we recently talked about writing a "gitconfig" encoder, even if it's not part of the main cuelang.org/go Go module, to implement the ini-like format documented at https://git-scm.com/docs/git-config. It is used elsewhere besides just Git, like for example Gerrit's https://gerrit-review.googlesource.com/Documentation/config-project-config.html, which we need to maintain due to our use of GerritHub, and we'd like to export from CUE.

So perhaps the two encoders could share some code as well, given their similarity. Or perhaps using existing Go packages for ini and gitconfig formats separately would be better, it depends on what is out there.