-
Notifications
You must be signed in to change notification settings - Fork 350
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
Feature/plugins v3spec part1 connect #73 #381
Conversation
Codecov Report
@@ Coverage Diff @@
## master #381 +/- ##
==========================================
- Coverage 91.46% 91.28% -0.18%
==========================================
Files 197 204 +7
Lines 8349 8521 +172
==========================================
+ Hits 7636 7778 +142
- Misses 713 743 +30
Continue to review full report at Codecov.
|
this.logger = logger; | ||
this.settings = settings || {}; | ||
this.config = config; | ||
this.policies = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of exposing the underlying data structure, what do you think about registration functions? manifest.registerPolicy
instead of manifest.policies.push
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
lib/plugins.js
Outdated
}; | ||
}; | ||
|
||
class PluginManifest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the concept of "manifest" is a little strange in this context. I think of a manifest as a file living outside the code that contains metadata about the contents of the project, usually written in a config format like XML, JSON, or INI. I get that it's serving a similar purpose, but I look at this in code and think, "Gee, is this telling me I can actually put this manifest in a separate config file?" This might be a bias based on my past experiences. Not sure. Also, feels a tad more weird when we start assigning event handlers. Just thought I'd toss this out there. Would it make more sense to just call this... Plugin
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it looks weird to common approach like that
https://developer.chrome.com/extensions/manifest
the thing is that what it passes is not a plugin, because plugin is entire package itself.
It is something like container/ plugin manager / context.
I cannot name it pluginOptions because it will be confused with parameters and settings
Just to clarify, this PR doesn't include support for the following extensions:
Is that correct? |
and no CLI extensions as well |
@@ -8,6 +8,9 @@ db: | |||
cli: | |||
url: http://localhost:9876 | |||
|
|||
plugins: | |||
# eg-example-plugin: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
express-gateway-plugin-example
would be the package name, the actual plugin name would be example
in the system.config.yml
?
for example:
express-gateway-plugin-oauth2
would be the npm module the entry within system.config.yml
- oauth2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, make sense. and if user needs to install non convention package they will have 'package' word for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section basically acts as a whitelist, yeah?
If so, why do we need a whitelist if the package has already been explicitly installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like concept installed vs enabled. Same idea as behind policies - have many registered(installed), but use only whitelisted(enabled).
It seems to be standard pattern for plugins. Because installation is typically complex process and enable\disable is 1 sec operation.
Atom\VS Code\Sublime all have that. Kong - same idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even ExpressJS - installed middleware, unless it is used in code doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. So it's not really a "whitelist" of allowed plugins; it's just a signal to enable. We could have discovery logic for finding a package listed here.
- Try wrapping the package name in
express-gateway-${name}-plugin
. - If that fails, try
${name}
. - Error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point I've implemented the logic
read settings for ${name}
if contains package
-> require('package')
else ensure name
is prefixed with express-gateway-plugin-
-> require(name)
So if you really want different name, np use package
property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 sounds good to me, the plugins:
is so that there is a known declaration and exposure to what global params are in place
simliarly in policies:
you can have policies installed but unless you declare it, it can't be referenced in a pipeline
lib/plugins.js
Outdated
registerAdminExtension (adminExtension) { | ||
this.adminExtensions.push(adminExtension); | ||
} | ||
registerCliExtension (cliExtension) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For acronyms in JavaScript identifiers, I use all capital letters as the convention, taken from some built-ins like encodeURIComponent
. Would you be willing to switch this to registerCLIExtension
?
2657d10
to
77232c1
Compare
support for admin extensions support for express-gateway extensions like routes and middleware loading plugin conditions plugin: policy test and replacing direct policy registration for some tests with plugin based approach
77232c1
to
20288c9
Compare
@altsang @kevinswiber please take a look once again. The main difference for last commit it is now possible to provide entire config to it allows test code without having real config file loaded first Another difference is that previously it was a trick to load fake test policies, now it is possible to just use plugins for that. Some tests where refactored with this approach |
Hmm. So I'm actually running into an issue trying to load plugins. The
But I can require it just fine in server.js. |
Just found this. I think we should use it. Looks like it can be an issue for people developing plugins. Let's circumvent it. It fixed the problem for me. |
Jared's stuff is solid 👍 |
parent-require is integrated |
Final v1.0 version