Giter Site home page Giter Site logo

Add API versioning about agent HOT 3 CLOSED

portainer avatar portainer commented on May 21, 2024
Add API versioning

from agent.

Comments (3)

kendrickm avatar kendrickm commented on May 21, 2024

So based on reading some different blog posts, we will want to move all the current versions into a v1 namespace with the name prepended with a starting version. We could either use date+timestamps or just an incrementing number. Because of the global nature of development and use, spanning many time zones, I propose just incrementing a single int for the version number(1,2,3 etc) vs a timestamp.

If we want to be able to support older versions of the api(for bug fixes etc) we could add a - or _ in the version number(1-1 etc) or (1_1 etc)

The challenge with the first option (the hypen - ) is we can not name the go functions the same thing(ie browsePut1-1 is an invalid method name) so the function name would be slightly different then the api version, could be an underscore or no special character.

If instead we use an underscore(_) in the URL it creates URLs that could be harder to parse(some API libraries have shown issues parsing urls with _) but since we control the consumption of this API we it might be less of a problem.

Once the version scheme is decided, the next question is how much to scope into a version of the API.
Only the browse API is changing with v2, but I think we should support calls for v2 to other api's just for consistency, even if the other apis aren't changing.

So the changes required would be to rename all our existing browse API's to be V1 first.

ex func (handler *Handler) browsePut becomes func (handler *Handler) browsePutV1 etc

Then merge the changes from feat8-refactor-browse branch and name those functions latest, along with all other APIs in other packages besides browse.
ex in package http/handler/docker rename (handler *Handler) dockerOperation to (handler *Handler) dockerOperationLatest etc.

Then update the ServeHTTP method to strip v1 out of the URL and send any requests to the v1 functions. Also strip out v2 and then send any requests with v2(or no version) to the latest functions.

from agent.

deviantony avatar deviantony commented on May 21, 2024

If we want to be able to support older versions of the api(for bug fixes etc) we could add a - or _ in the version number(1-1 etc) or (1_1 etc)

I don't think we need this. If a bug is detected in a specific version of the API (and thus related to the agent, our instruction will be to simply update the agent to a version that includes the fix).

Version scheme v1, v2, vX ok for me.

Only the browse API is changing with v2, but I think we should support calls for v2 to other api's just for consistency, even if the other apis aren't changing.

Yes.

Then merge the changes from feat8-refactor-browse branch and name those functions latest, along with all other APIs in other packages besides browse.
ex in package http/handler/docker rename (handler *Handler) dockerOperation to (handler *Handler) dockerOperationLatest etc.

No need to append Latest to each handler, each handler without a version suffix should be considered the latest version of the handler.

We should start with a PR affecting the browse and agent API endpoints first, we'll review it and then go further with the whole API.

from agent.

deviantony avatar deviantony commented on May 21, 2024

In order to solve portainer/portainer#2364 I think that as a part of this work we should also introduce a new Header returned by all the agent responses that would include the current version of the Agent API.

This could be added next to the Agent version header: https://github.com/portainer/agent/blob/develop/http/server.go#L44

from agent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.