Skip to content

Conversation

@thaJeztah
Copy link
Member

Add a package to help augmenting API responses with additional fields, replacing fields, or to remove fields from the response to allow for legacy API responses to be produced without having to keep deprecated fields in the API type definitions.

- 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)

@thaJeztah
Copy link
Member Author

Found this one back in my stash; was pretty much work in progress with some options I was playing with

cc @austinvazquez @akerouanton

@austinvazquez
Copy link
Contributor

This LGTM and I know at least one example where it could have been useful. i.e. #50826 had some specific logic for that use case.

@thaJeztah
Copy link
Member Author

Yeah, I didn't want to move it out of draft if we wouldn't be using it (yet), but if you think it would make sense to re-implement the existing ones with this, we could.

One thing I'm not sure of in this patch is if the use of generics adds much value; ISTR originally I had the WithExtraFields (etc.) arguments also "typed", but that made them more complicated to use (combat.WithExtraFields[<some type>](....)). That was removed before I pushed this, but the type Wrapper[T any] struct { still has; and not sure if it brings real benefits.

I may have had other code using generics originally, but recall that I simplified the patch (but don't think I still have earlier implementations around).

Add a package to help augmenting API responses with additional fields,
replacing fields, or to remove fields from the response to allow for
legacy API responses to be produced without having to keep deprecated
fields in the API type definitions.

Co-authored-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Sep 10, 2025
@thaJeztah thaJeztah added this to the 29.0.0 milestone Sep 10, 2025
@thaJeztah thaJeztah marked this pull request as ready for review September 10, 2025 22:14
@thaJeztah
Copy link
Member Author

@akerouanton I applied your commit that removed the generics and squashed it to a single commit (adding you as co-author); I was just also working on a PR that could use this one, so we can probably get this one in already as a separate one.

@thaJeztah
Copy link
Member Author

I'll bring this one in

@thaJeztah thaJeztah merged commit e4c9d28 into moby:master Sep 11, 2025
185 checks passed
@thaJeztah thaJeztah deleted the add_compat_wrapper branch September 11, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants