-
Notifications
You must be signed in to change notification settings - Fork 2
feat(cmd): add --output-format json flag for CI/CD result envelope #242
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -68,7 +68,9 @@ func (cmd *UpCmd) Run( | |||||||||
|
|
||||||||||
| wctx, err := cmd.executeDevsyUp(ctx, devsyConfig, client) | ||||||||||
| if err != nil { | ||||||||||
| _ = config2.WriteErrorJSON(os.Stdout, err.Error()) | ||||||||||
| if cmd.OutputFormat == flags.OutputFormatJSON { | ||||||||||
| _ = config2.WriteErrorJSON(os.Stdout, err.Error()) | ||||||||||
| } | ||||||||||
| return err | ||||||||||
| } | ||||||||||
| if wctx == nil { | ||||||||||
|
|
@@ -80,24 +82,30 @@ func (cmd *UpCmd) Run( | |||||||||
| } | ||||||||||
|
|
||||||||||
| if err := cmd.configureWorkspace(devsyConfig, client, wctx); err != nil { | ||||||||||
| _ = config2.WriteErrorJSON(os.Stdout, err.Error()) | ||||||||||
| if cmd.OutputFormat == flags.OutputFormatJSON { | ||||||||||
| _ = config2.WriteErrorJSON(os.Stdout, err.Error()) | ||||||||||
| } | ||||||||||
| return err | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if err := cmd.openIDE(ctx, devsyConfig, client, wctx); err != nil { | ||||||||||
| _ = config2.WriteErrorJSON(os.Stdout, err.Error()) | ||||||||||
| if cmd.OutputFormat == flags.OutputFormatJSON { | ||||||||||
| _ = config2.WriteErrorJSON(os.Stdout, err.Error()) | ||||||||||
| } | ||||||||||
| return err | ||||||||||
| } | ||||||||||
|
|
||||||||||
| containerID := "" | ||||||||||
| var warnings []string | ||||||||||
| if wctx.result != nil { | ||||||||||
| if wctx.result.ContainerDetails != nil { | ||||||||||
| containerID = wctx.result.ContainerDetails.ID | ||||||||||
| if cmd.OutputFormat == flags.OutputFormatJSON { | ||||||||||
| containerID := "" | ||||||||||
| var warnings []string | ||||||||||
| if wctx.result != nil { | ||||||||||
| if wctx.result.ContainerDetails != nil { | ||||||||||
| containerID = wctx.result.ContainerDetails.ID | ||||||||||
| } | ||||||||||
| warnings = wctx.result.HostWarnings | ||||||||||
| } | ||||||||||
| warnings = wctx.result.HostWarnings | ||||||||||
| _ = config2.WriteResultJSON(os.Stdout, containerID, wctx.user, wctx.workdir, warnings) | ||||||||||
| } | ||||||||||
|
Comment on lines
+107
to
108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Same silent-discard pattern as - _ = config2.WriteResultJSON(os.Stdout, containerID, wctx.user, wctx.workdir, warnings)
+ return config2.WriteResultJSON(os.Stdout, containerID, wctx.user, wctx.workdir, warnings)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| _ = config2.WriteResultJSON(os.Stdout, containerID, wctx.user, wctx.workdir, warnings) | ||||||||||
| return nil | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
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.
JSON envelope is interleaved with container command output on stdout.
execInContainerwiresos.Stdoutas the container process's stdout (line 414), so any command output is already flushed there. TheWriteResultJSONcall then appends the JSON object to the same stream. A CI/CD consumer expecting clean JSON on stdout will receive something like:making the envelope unparseable by a standard JSON decoder. Common resolutions: write the envelope to a dedicated file/fd, move it to stderr, or redirect the container process's stdout to a buffer that gets embedded in the envelope.
🤖 Prompt for AI Agents