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

[WIP] Keep empty lines #1755

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

felixfontein
Copy link
Contributor

One annoying thing with SOPS-encrypted files is that all whitespace is normalized, and most importantly empty lines are removed.

I've been thinking for some time whether we can do better, so I did an experiment:

  • DotEnv: works fine.
  • INI: no way to access empty lines during parsing or emitting. This is due to the INI library used (gopkg.in/ini.v1).
  • JSON: no way to access empty lines during parsing or emitting. This is due to the JSON library used (Golang's JSON encoder/decoder).
  • YAML: it's possible to emit newlines, but no way to get them during parsing. One can try to use the line numbers from the node objects, but one has no idea how many lines the node itself needed, so no chance....

I guess for JSON it's OK to ignore newlines, but for INI and YAML it would be really nice. Especially for YAML, which I consider the main format for SOPS. Maybe this will be better with https://github.com/goccy/go-yaml...

I'm creating a PR for this experiment so that others can take a look, and maybe it's possible to improve on this once/if we switch to https://github.com/goccy/go-yaml.

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

Successfully merging this pull request may close these issues.

1 participant