Versioned API types for docker inspect.#16200
Closed
calavera wants to merge 1 commit intomoby:masterfrom
Closed
Conversation
58628c8 to
f7a18d9
Compare
Member
|
I was working on something similar. I was looking at going a step further and defining the full type (instead of using a base struct) for each API version and defining a conversion for a container to the API version. Which would ensure a change doesn't break an older API version IMO is a bit easier to read. But may cause some extra work in cases where there are API changes. |
Contributor
|
There are some other API needs to do this too. |
f7a18d9 to
da05e61
Compare
Currently, we version returning types in the api with prefix in the type names. This is not ideal. This change introduces the concept of versioned types using go packages. The types are much more isolated, easy to find and implement. This change also introduces the concept of struct decorators. Currently, the api types are leaked into the daemon package because we need the daemon functions to return api types. This introduces a high coupling between the api and the daemon. At the end of the day, we should not use anything under `api` in the damon package. The decorators are functions in charge of tranforming a typed value provided by the daemon into serializable objects to be returned by the api. Signed-off-by: David Calavera <david.calavera@gmail.com>
da05e61 to
fdc97f5
Compare
Contributor
Author
|
I'm not going to push this forward for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, we version returning types in the api with prefix in the type
names. This is not ideal.
This change introduces the concept of versioned types using go packages.
The types are much more isolated, easy to find and implement.
This change also introduces the concept of struct decorators. Currently,
the api types are leaked into the daemon package because we need the
daemon functions to return api types. This introduces a high coupling
between the api and the daemon. At the end of the day, we should not use
anything under
apiin the damon package.The decorators are functions in charge of tranforming a typed value
provided by the daemon into serializable objects to be returned by the
api.
Signed-off-by: David Calavera david.calavera@gmail.com