[experiment] First approach to extensible shell with plugins#1416
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
shellcommand that starts an interactive shell with autocomplete and history capabilities that will load dynamically any commands found in~./elastic-package/shell_plugins3- Adds some example commands under
pkg/shell/plugins.The idea behind that would be to, if moved forward, have a new ie
pluginsrepository 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
internalto iepkgsome 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 installor create the shell_plugins directory if already installedmkdir ~/.elastic-package/shell_plugins3- Build the test plugins
cd pkg/shell/plugins; go build -buildmode=plugin ./...; mv plugins.so ~/.elastic-package/shell_plugins4- In integrations, run
elastic-package shell5- Play with the provided commands