Skip to content

Versioned API types for docker inspect.#16200

Closed
calavera wants to merge 1 commit intomoby:masterfrom
calavera:versioned_api_types
Closed

Versioned API types for docker inspect.#16200
calavera wants to merge 1 commit intomoby:masterfrom
calavera:versioned_api_types

Conversation

@calavera
Copy link
Contributor

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

@cpuguy83
Copy link
Member

I was working on something similar.
+1 to the decorators here.

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.

@HuKeping
Copy link
Contributor

There are some other API needs to do this too.

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>
@calavera
Copy link
Contributor Author

I'm not going to push this forward for now.

@calavera calavera closed this Sep 24, 2015
@calavera calavera deleted the versioned_api_types branch September 24, 2015 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants