Consistently use STDERR for output. #647
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is basically these commands (I also renamed a variable in the output-capture code):
(some context around motivation)
I have been experimenting with adding inline keyless verification in downstream tooling with:
(and similar for keyless signing, but that's more verbose currently, so omitted)
However, some of these tools reserve STDOUT to enable command composition, e.g.
kn service create foo --image=$(ko publish ./cmd/bar)
So if (in this illustrative example) we wanted
ko
to automatically verify base images whenCOSIGN_EXPERIMENTAL=true
then we would need all of the output fromcli.Verify().Exec(...)
to either go to STDERR, or surface some capacity for redirecting output (similar to cobra'scmd.Set{Out,Err}
methods).There is some existing logic to redirect STDOUT to a file, but I couldn't really discern a pattern for what goes to STDOUT vs. STDERR. The two general motivations for this (I'd assume) would be:
ko publish
emits a digest to STDOUT, and nothing else; but there is no obvious schema to any of the paths I looked at...?)So I'm assuming that the motivation is
1.
, and "fixing" it to capture STDERR here, but it would be good to get some eyeballs on this that are more familiar with the motivation for capturing output to make sure this isn't somehow breaking (let's see what the tests say)!Signed-off-by: Matt Moore mattomata@gmail.com