-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[cli] Emit JSON events for updates via --json
flag
#8275
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we should add testing, and I have a couple of very minor nits.
In general, LGTM.
ed8a13f
to
75f7303
Compare
@@ -169,7 +171,7 @@ func newDestroyCmd() *cobra.Command { | |||
Scopes: cancellationScopes, | |||
}) | |||
|
|||
if res == nil && len(*targets) == 0 { | |||
if res == nil && len(*targets) == 0 && !jsonDisplay { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. 👍
|
||
return encoder.Encode(apiEvent) | ||
} | ||
|
||
func startEventLogger(events <-chan engine.Event, done chan<- bool, opts Options) (<-chan engine.Event, chan<- bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does --json
interact with the event logger? I'm guessing from the way things are factored that they will work together just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah they work together just fine, and in fact the test uses the event log to ensure all events from the event log are present in the stdout output.
75f7303
to
071515a
Compare
This feature is especially important for Automation API when you want to customize the output. No need to parse text. |
@komalali Pardon my ignorance to properly do the research. Thanks for the information! |
Description
This PR adds a
--json
flag toup
,destroy
andrefresh
and streams json events to stdout when the flag is passed.For
preview
, the existing functionality of outputting a JSON object at the end of preview is maintained. However, the streaming output can be extended topreview
by using thePULUMI_ENABLE_STREAMING_JSON_PREVIEW
environment variable.I added some tests, ready for review.
Follow-up Work
Fixes #2390
Checklist