Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(kuma-cp) add customizable API #1174

Merged
merged 5 commits into from
Nov 23, 2020
Merged

Conversation

nickolaev
Copy link
Contributor

Summary

Adding customizable API.

Documentation

  • Not needed

Nikolay Nikolaev added 2 commits November 20, 2020 19:56
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@nickolaev nickolaev marked this pull request as ready for review November 23, 2020 09:35
@nickolaev nickolaev requested a review from a team as a code owner November 23, 2020 09:35
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

ws := new(restful.WebService).Path(path)
ws.Route(ws.GET(subpath).To(handler))
c.Add(ws)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if you need something like Auth on this endpoint or filter of logging requests or add an extra method to this webservice?

I think I'd drop this method and do these 3 lines on the APIManager client that will just use Add. That's not really extensible API, you cannot add filters, change the method, add many methods to ws, add OpenAPI docs etc.


apiServer := createTestApiServer(resourceStore, cfg, true, metrics, wsManager)

stop := make(chan struct{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close the channel

return apiServer
}

var SampleTrafficRouteWsDefinition = definitions.ResourceWsDefinition{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this for a test

@@ -71,7 +73,8 @@ func init() {
}
}

func NewApiServer(resManager manager.ResourceManager, defs []definitions.ResourceWsDefinition, cfg *kuma_cp.Config, enableGUI bool, metrics metrics.Metrics) (*ApiServer, error) {
func NewApiServer(resManager manager.ResourceManager, wsManager customization.APIInstaller,
defs []definitions.ResourceWsDefinition, cfg *kuma_cp.Config, enableGUI bool, metrics metrics.Metrics) (*ApiServer, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting nit. For me, it's easier to read arguments grouped in one line or every in it's own line so either

func NewApiServer(resManager manager.ResourceManager, wsManager customization.APIInstaller, defs []definitions.ResourceWsDefinition, cfg *kuma_cp.Config, enableGUI bool, metrics metrics.Metrics) (*ApiServer, error) {

or

func NewApiServer(
    resManager manager.ResourceManager,
    wsManager customization.APIInstaller,
    defs []definitions.ResourceWsDefinition,
    cfg *kuma_cp.Config,
    enableGUI bool,
    metrics metrics.Metrics,
) (*ApiServer, error) {

@@ -135,6 +138,10 @@ func NewApiServer(resManager manager.ResourceManager, defs []definitions.Resourc
} else {
container.ServeMux.HandleFunc("/gui/", newApiServer.notAvailableHandler)
}

// Install the custom WS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think this comment is needed. I like commenting out code for the following reasons

  1. explaining why something is happening
  2. explaining code design and design decisions / tradeoffs
  3. explaining difficult code when language is crippling the developer to write an easy to understand code

Here it's pretty obvious what is going on

@jakubdyszkiewicz
Copy link
Contributor

it's chore(kuma-cp)

@nickolaev nickolaev changed the title chore(*) add customizable API chore(kuma-cp) add customizable API Nov 23, 2020
Nikolay Nikolaev added 2 commits November 23, 2020 12:51
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@nickolaev nickolaev merged commit 598dedd into master Nov 23, 2020
@nickolaev nickolaev deleted the chore/customizable_api branch November 23, 2020 11:51
mergify bot pushed a commit that referenced this pull request Nov 23, 2020
* chore(*) add customizable API

* chore(*) move to APIManager

* chore(*) introduce APIManagaer, bootstrapBefore and After

Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
(cherry picked from commit 598dedd)
nickolaev pushed a commit that referenced this pull request Nov 23, 2020
* chore(*) add customizable API

* chore(*) move to APIManager

* chore(*) introduce APIManagaer, bootstrapBefore and After

Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
(cherry picked from commit 598dedd)

Co-authored-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants