Implementing backward compatibility for engine-api users
Hi,
This is more of a question - I've been thinking about how to use the backward compatibility structs defined in https://github.com/docker/engine-api/tree/master/types/versions/. The older structs are implemented there, but the method signatures in the interface only refer to the latest ones.
What's the recommended way to implement functions that make use of legacy structs?
Also, is there any reason why p1v18 isn't part of the backward compatibility versions?
Thanks!
cc @calavera @dongluochen
I think the only reasonable way we've found to do this is by checking the version in the http request. I'm super open to suggestions, but I don't think there is any easy way to handle those. See what we do for docker inspect:
https://github.com/docker/docker/blob/master/daemon/inspect.go#L19-L27
Re p1v18: there was nothing defined to keep backward compatibility around before p1v19 :sob:
Thanks @calavera.
For reference, here's how Engine does it by defining a separate function: https://github.com/docker/docker/blob/2658341b5fe9dec5c4839f0721219111fb08b43f/daemon/inspect_unix.go#L24
And then using a wrapper function: https://github.com/docker/docker/blob/2658341b5fe9dec5c4839f0721219111fb08b43f/daemon/inspect.go#L19
(Thanks to @tiborvass for pointing that out).
Also, a related issue is this, requiring to always specify API version: https://github.com/docker/docker/issues/21157
(cc @thaJeztah)