Hello,
Plugins will be part of the next release and here is my proposal for the plugin system / interface.
Plugin definition
Plugin is a self-sustaining package which adds extra functionality to the Cast agent. Plugin packages mirror NPM package format which means they can be distributed using NPM and published on the NPM registry.
Plugins can be placed in an arbitrary directory on the agent server, but the user must specify plugin root directory and an object with the enabled plugins and their settings in the Cast config file.
Plugin part of the config file could look something like this:
"plugins": {
"root": "/data/cast-plugins/", // can be a relative or an absolute path. If it's relative, it is joined with the Cast data directory
"enabled": {
"github": {
"username": "foobar",
"api_token": "…"
}
}
}
Resources and functionalities which plugins can provide / expose
For example, a Github plugin could provide a single HTTP endpoint which Github Webhook would hit. Hitting this endpoint would trigger a bundle creation and an application which is hosted in this git repository would be upgraded.
Plugin directory structure
plugin_name/
plugin_name/package.json -> contains all the required NPM fields and some Cast specific stuff. name field in this file should always be prefixed with "cast"
plugin_name/lib/core.js -> core plugin functionality
plugin_name/lib/services/ -> contains services
plugin_name/lib/http/ -> contains http api endpoints
plugin_name/lib/jobs/ -> contains jobs
Plugin specific settings in plugin package.json
Installing, enabling, disabling and removing plugins
To make the whole process easier we should probably also add "plugins" command to the client. This will be especially useful in Cast cluster version when user will want to distribute plugins to multiple servers.
"plugins" command would have the following sub-commands:
Open questions
We have already discussed a bit about this on the IRC channel, but there are still many open questions so feedback is more than welcome.
I will also try to post a sample plugin soon which will give you more context and details about some of the plugin APIs.
Thanks,
Tomaz
{
"available": {
"username": {
"type": "string"
},
"api_token": {
"type": "string"
},
"project_names": {
"type": "array"
}
},
"configured": {
"username": "user",
"api_token": "barfo123456",
"project_names": ["project1", "project2"]
}
}