Skip to content

[WIP] dismantle pkg/jsonstream, pkg/streamformatter, pkg/progress#50564

Draft
thaJeztah wants to merge 9 commits intomoby:masterfrom
thaJeztah:move_jsonstream
Draft

[WIP] dismantle pkg/jsonstream, pkg/streamformatter, pkg/progress#50564
thaJeztah wants to merge 9 commits intomoby:masterfrom
thaJeztah:move_jsonstream

Conversation

@thaJeztah
Copy link
Member

This may take some time to fully untangle;

  • pkg/jsonstream is used to unmarshal a struct that doesn't appear to have a type in the API
  • pkg/streamformatter uses the pkg/jsonstream type
  • it refers to "this is used for events', but events actually have a events.Message type
  • .. which is similar, but not identical

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

formatted = out.sf.formatStatus(prog.ID, prog.Message)
} else {
jsonProgress := jsonmessage.JSONProgress{Current: prog.Current, Total: prog.Total, HideCounts: prog.HideCounts, Units: prog.Units}
jsonProgress := jsonmessage.JSONProgress{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

streamformatter at a glance looks to be what's used to produce API responses in various places, but it looks to be needing the raw types from the API; currently it uses the jsonmessage package - need to look if we can unwrap that and use types from the API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and then it uses yet-another type; it uses progress.Progress from pkg/progress, which looks rather similar to the type I introduced in this PR, so perhaps that's the one we SHOULD be looking for to move to the API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think with the current API shape I think it makes sense to include these in the API...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying some bits (just pushed some hacky commits), but it's ... really messy, and not clear which type in pkg/ corresponds with which actual response (looking into some of those).

@thompson-shaun thompson-shaun added this to the 29.0.0 milestone Jul 29, 2025
type jsonMessage struct {
Stream string `json:"stream,omitempty"`
Status string `json:"status,omitempty"`
Progress *jsonmessage.JSONProgress `json:"progressDetail,omitempty"` // TODO(thaJeztah): can this be a [jsonstream.Progress]?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is fine, the jsonmessage library will decode it anyway. The unexported fields can't be used anyway, its only used internally in the jsonmessage package.

@thaJeztah thaJeztah force-pushed the move_jsonstream branch 4 times, most recently from a3fcb71 to 59ddeb1 Compare July 30, 2025 11:16
thaJeztah and others added 9 commits July 30, 2025 14:22
Also rename api type JSONError to Error

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Move the type to the API, but embed it, so that we keep the
methods on the struct in this package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This package depends on jsonformatter.JSONProgress and jsonmessage.JSONMessage,
and it looks like it requires some of those for their stringer interface.

Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The API still returns it for backward-compatibility (but probably
shouldn't), but we should no longer print it. This removes the
fields, and their use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@vvoland vvoland modified the milestones: 29.0.0, 29.1.0 Nov 10, 2025
@vvoland vvoland modified the milestones: 29.1.0, v-future Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants