-
Notifications
You must be signed in to change notification settings - Fork 116
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
[experiment] First approach to extensible shell with plugins #1416
base: main
Are you sure you want to change the base?
Conversation
61a3a51
to
bb6a0e7
Compare
I also experimented with https://github.com/hashicorp/go-plugin to avoid some of the brittleness issues native plugins have. Pros from RPC plugins: 1- less brittle (no need to be compiled with same versions of toolchain and dependencies) Cons: 1- The usable interface for the commands is much more limited. No possibility to send Native plugins are more convenient if we find reliable automation to solve their issues and we acknowledge the lack of WIndows support, and RPC ones are easier to maintain if we get to a good middle ground for the commands interfaces at use. |
Added one more commit with an RPC implementation. Currently it has several limitations compared with the original one: 1- Shared After building the boilerplate creating new commands is straightforward, and overall I think this is a much more robust approach. How to try it: 1- Fetch this branch |
0d7f732
to
9bd70c6
Compare
Extracted the required internal packages to |
This addition is great! really looking forward to see something like this getting merged at some point :) |
c29bf72
to
1cdb985
Compare
💚 Build Succeeded
History
cc @marc-gr |
For some time there have been discussions about how to extend elastic-package capabilities in a way that does not require changes in elastic-package codebase (ref #479).
I have explored this approach of an interactive shell that can be extended with Go plugins, for example to extend it with adhoc commands to do bulk operations, or to add other experimental capabilities to be tested.
This first experimental approach:
1- Describes a Command interface that the plugins need to follow.
2- Adds a
shell
command that starts an interactive shell with autocomplete and history capabilities that will load dynamically any commands found in~./elastic-package/shell_plugins
3- Adds some example commands under
pkg/shell/plugins
.The idea behind that would be to, if moved forward, have a new ie
plugins
repository that could be built independently and which artifacts would be placed in the before mentioned directory.A requirement for this would be to move from
internal
to iepkg
some of the most used packages that can interact with packages to allow importing them from the plugins repository.This setup would allow for much faster experimentation of new functionalities and to have it more isolated. If at some point we want to move some of this plugins to be builtin it should be a straightforward process since they will be using the elastic-package dependencies.
How to test it:
1- Fetch this branch
2- Install elastic-package
$ make install
or create the shell_plugins directory if already installedmkdir ~/.elastic-package/shell_plugins
3- Build the test plugins
cd pkg/shell/plugins; go build -buildmode=plugin ./...; mv plugins.so ~/.elastic-package/shell_plugins
4- In integrations, run
elastic-package shell
5- Play with the provided commands