hiera-eyaml
hiera-eyaml copied to clipboard
Trailing newline is added during encryption/decryption
Hiera eyaml 2.1.0 ensures there is a trailing newline when run from the command line.
❯ echo -n nonl >no_newline
❯ od -c no_newline
0000000 n o n l
0000004
❯ eyaml encrypt -f no_newline -o string | tr -d '\n' | eyaml decrypt --stdin | od -c
0000000 n o n l \n
0000005
❯ echo yesnl >yes_newline
❯ od -c yes_newline
0000000 y e s n l \n
0000006
❯ eyaml encrypt -f yes_newline -o string | tr -d '\n' | eyaml decrypt --stdin | od -c
0000000 y e s n l \n
0000006
This is inconsistent. It should either add the newline (nonl\n
and yesnl\n\n
) or not add the newline (nonl
and yesnl\n
).
Originally #264, though I got the title backward that time. Thanks to @bifek for finding a good test case.
encryption is fine. even decryption itself is fine, it's only in emitting the output that it unnecessary adds newline. see #270
A simpler example:
❯ eyaml encrypt -s nonl -o string | tr -d '\n' | eyaml decrypt --stdin | od -c
0000000 n o n l \n
0000005
Hi folks,
I'd like to add that this issue seems to only manifest in eyaml output mode string. If I use the block output (and the according syntax in hiera itself) the output is what you would expect.
Might help to narrow down the issue.
EDIT: well this somehow is obvious from the examples above because -o string
is used, but I thought I'd spell it out.
Cheers Thomas
in my testing this is the same
% { echo '>'; echo -n nonl | eyaml encrypt --stdin -o block; } | eyaml decrypt --stdin | od -c
0000000 n o n l \n