Repository navigation
Conversation
|
I tried adding tests with in tests/pytests/integration/cli/test_salt.py and also attempted a few variations of placing the Can I get regular / unfiltered CLI output in the test suite somehow? |
|
this isn't really how you want to go about fixing this. salt.client really shouldn't be printing to stdout or stderr at all, but that's just an unfortunate side effect of how someone wrote this originally. you really want something like this: can you explore testing this patch and updating your PR? |
|
Hi @mattp-, thanks for your input and the better solution - I will test, but from briefly reading over your patch, it seems it would cause the jid to not be printed at all if operating with the json or yaml output mode? I understand why, however think it would still be useful to have it available - maybe at least for JSON mode, should we print it as a separate JSON object? |
|
no, it would. implicitly the jid is in the 'full_return'/raw load returned over the wire; i should have pasted an output example: |
|
@tacerus is this still something you are interested in getting merged? We are working on merging for 3009. |
When using --out=json, all data sent to stdout should be valid JSON to allow for piping into processing tools such as `jq`. Make this the case with "show_jid" being enabled as well, by printing the JID line to stderr instead of stdout. Signed-off-by: Georg Pfuetzenreuter <[email protected]>
Test all three get_cli_* methods and update the existing functional test to assert jid: line appears on stderr, not stdout, keeping --out=json stdout valid JSON. Fixes saltstack#25154.
What does this PR do?
When using --out=json, all data sent to stdout should be valid JSON to allow for piping into processing tools such as
jq. Make this the case with "show_jid" being enabled as well, by printing the JID line to stderr instead of stdout.What issues does this PR fix or reference?
Fixes #25154 (the issue was closed with
--staticbeing suggested as a solution, however this to me is merely a workaround, as it makes for a different output strategy).Previous Behavior
With
show_jidenabled, piping into JSON processing tools leads to parsing exceptions.New Behavior
stdout can be processed as JSON with
show_jidenabled, the same way as withshow_jiddisabled.Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes