Skip to content

Conversation

gandro
Copy link
Member

@gandro gandro commented Nov 16, 2023

This PR extends the Cilium API server cell with the ability to inject a global middleware. The middleware injected here is a global executed after the middlewares injected by setupGlobalMiddleware, but before the API method dispatch. See [1] for more details.

This allows the Hive-injected middleware to benefit from global middleware handlers such as our panic and metrics handlers, but before any swagger specific handlers are called. The middleware is optional, as it is intended to be used for out-of-tree API implementations. The middleware parameter is named, so it only applies to a particular
OpenAPI spec, thereby allowing for specialization of that API.

[1] https://goswagger.io/use/middleware.html

The other two commits in this PR are quality-of-life improvements for users with custom API extensions.

This allows other Makefiles in the tree to pull in those definitions if
they also want to invoke Swagger. There is one functional change too:
Instead of using CURDIR, we're now using ROOT_DIR in the container
volume mount. This has no impact for the existing code (where CURDIR ==
ROOT_DIR), but allows Makefiles in subdirectories to mount the full Go
module (instead of just their subdirectory), which is needed for Swagger
code gen.

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
@gandro gandro added area/daemon Impacts operation of the Cilium daemon. release-note/misc This PR makes changes that have no direct user impact. area/modularization Relates to code modularization and maintenance. labels Nov 16, 2023
@gandro gandro requested review from a team as code owners November 16, 2023 11:40
@gandro gandro requested review from aanm and asauber November 16, 2023 11:40
@maintainer-s-little-helper

This comment was marked as resolved.

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Nov 16, 2023
This commit extends the Cilium API server cell with the ability to
inject a global middleware. The middleware injected here is a global
executed after the middlewares injected by `setupGlobalMiddleware`, but
before the API method dispatch. See [1] for more details.

This allows the Hive-injected middleware to benefit from global
middleware handlers such as our panic and metrics handlers, but before
any swagger specific handlers are called. The middleware is optional, as
it is intended to be used for out-of-tree API implementations. The
middleware parameter is named, so it only applies to a particular
OpenAPI spec, thereby allowing for specialization of that API.

[1] https://goswagger.io/use/middleware.html

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
This commit makes the API basepath configurable. This is useful to build
clients where the API is accessed via a reverse proxy.

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
@gandro gandro force-pushed the pr/gandro/api-middleware branch from 9918581 to 02c313e Compare November 16, 2023 11:40
@maintainer-s-little-helper

This comment was marked as resolved.

@gandro gandro removed the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Nov 16, 2023
@gandro
Copy link
Member Author

gandro commented Nov 16, 2023

/test

Edit:

@gandro
Copy link
Member Author

gandro commented Nov 16, 2023

/ci-eks

@gandro gandro removed the request for review from asauber November 20, 2023 10:27
@gandro gandro merged commit 1b0bb06 into cilium:main Nov 20, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/daemon Impacts operation of the Cilium daemon. area/modularization Relates to code modularization and maintenance. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants