-
Notifications
You must be signed in to change notification settings - Fork 63
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
YAML support #175
Comments
Example wrapper script for YAML: #!/bin/bash -e
declare -A map;
args=("$@")
for i in "${!args[@]}"; do
arg="${args[i]}";
# Guard clause: Skip if not an eYAML file
[[ ! -f "$arg" ]] && [[ ! $arg =~ *.eyml ]] && [[ ! $arg =~ *.eyml ]] && continue;
# Temporarily convert eYAML to eJSON
tmp=$(mktemp eyaml_XXXXXX.ejson);
trap 'rm -f "$tmp"' EXIT;
yq -ojson . "$arg" > "$tmp";
# Replace eYAML file with eJSON file
args[i]="$tmp";
map["$arg"]="$tmp";
done
case "$*" in
# Convert eJSON files back to eYAML
*"encrypt "*|*" encrypt"*|*" encrypt "*)
ejson "${args[@]}";
STATUS="$?";
for original in "${!map[@]}"; do
yq -P "${map[$original]}" > "$original";
done
exit $STATUS;
;;
# Convert JSON output to YAML
*"decrypt "*|*" decrypt"*|*" decrypt "*)
ejson "${args[@]}" | yq -P .;
;;
*)
ejson "${args[@]}";
;;
esac |
👋 there's nothing planned, but if these features are guarded by new flags/arguments PRs are welcome! https://github.com/getsops/sops/ supports YAML+JSON among other formats, might be worth checking out. |
Thank you for the prompt reply & the
I'll take a look at the ejson main package to see how hard adding yaml support would be. Thank you! |
From the architecture of the package I notice that there's a JSON walker implementation meant to take entries in the order they are found (to avoid randomizing the order of the output). With that in mind an
The walker approach seems to dig fairly "deep" into the implementation. Do you have a go/no-go for either of these? |
Hello,
I saw a tentative successor app that was eventually abandoned back in 2021 ecfg. Are there any (further) plans or alternatives for YAML support?
Currently a few design choices are making working with a wrapper script much harder:
encrypt
not writing output to stdoutyq -ojson . my.eyaml | ejson encrypt | yq -oyaml . | sponge my.eyaml
So "on the fly conversion" from an eyaml file to ejson to be used with this tool requires a temporary file + writing back into the original file (when encrypting).
Thank you,
Mihai
The text was updated successfully, but these errors were encountered: