Skip to content
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

api/types/container: InspectResponse: keep old name for embedded type #48124

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

thaJeztah
Copy link
Member

This is a follow-up to 1abc8f6 (#48057), which moved the ContainerJSONBase to api/types/container, but also renamed it to container.InspectBase. This field is embedded into the InspectResponse type, which meant that renaming the type also implicitly renamed the field when creating this type from a struct-literal.

While we're planning to merge these types (which would be a breaking change for users constructing it through struct-literals), let's keep it backward-compatible for now (other than deprecating the old names).

We can continue the other changes separately.

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

@thaJeztah thaJeztah added this to the 28.0.0 milestone Jul 3, 2024
@thaJeztah thaJeztah self-assigned this Jul 3, 2024
@thaJeztah
Copy link
Member Author

LOL... I thought this was supported, but not for JSON in stdlib; golang/go#6213 (comment)

So I guess we need to change the name back for now.

@thaJeztah thaJeztah force-pushed the api_types_inspectbase branch from c7a409a to d976412 Compare July 3, 2024 13:14
This is a follow-up to 1abc8f6, which
moved the ContainerJSONBase to api/types/container, but also renamed it
to container.InspectBase. This field is embedded into the InspectResponse
type, which meant that renaming the type also implicitly renamed the
field when creating this type from a struct-literal.

While we're planning to merge these types (which would be a breaking
change for users constructing it through struct-literals), let's keep
it backward-compatible for now (other than deprecating the old names).

We can continue the other changes separately.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the api_types_inspectbase branch from d976412 to fb18966 Compare July 3, 2024 15:14
@thaJeztah thaJeztah marked this pull request as ready for review July 3, 2024 15:17
@@ -167,7 +167,7 @@ type InspectBase struct {
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
// endpoint.
type InspectResponse struct {
*InspectBase
*ContainerJSONBase
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this also have a tag instead? *InspectBase `json:"ContainerJSONBase"?

(Is this really embedded into the JSON as "ContainerJSONBase": ...??? 😭)

Copy link
Member

Choose a reason for hiding this comment

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

If not, I don't actually understand how that PR broke this nor how this PR fixes it. 🙈

@tianon
Copy link
Member

tianon commented Jul 3, 2024

Oh, you don't necessarily mean it was broken for JSON, just that JSON also doesn't support inline -- what was broken was users constructing these in their Go code. I think I get it now. 👍

@thaJeztah
Copy link
Member Author

Oh, you don't necessarily mean it was broken for JSON, just that JSON also doesn't support inline -- what was broken was users constructing these in their Go code. I think I get it now. 👍

Yes, indeed; the previous change kept the JSON output the same, but it "broke" the Go side of things; users should still update their code to move to the new location, but with this PR at least it compiles (but printing "deprecation" warnings).

Given that the intent is for this nested struct to Go away (which will be an intentionally breaking change), it's not worth breaking people twice just to have a nicer name for something that will go away.

@thaJeztah thaJeztah merged commit 508cc7c into moby:master Jul 3, 2024
126 checks passed
@thaJeztah thaJeztah deleted the api_types_inspectbase branch July 3, 2024 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants