peru
peru copied to clipboard
Implement a way to chain plugins
There's currently no easy way to write a plugin which leverages an existing plugin. I can think of a few cases where it would be very helpful. For example:
- A
gh_repo
plugin which accepts a simple field likebuildinspace/peru
, builds the github url and the passes on the information to the git plugin via env vars - A
gh_release
plugin which queries the github API to find the latest release and the uses the curl plugin to download it.
I can think of two ways to support this:
-
plugin.yaml
has apre exe
(which manipulates the environment) and achain plug
orpass plug
or something which specifies the plugin which runs after thepre exe
- We could provide another entry point called something like
peru-plugin
. Plugins can call this command to leverage other plugins. However, this is probably not a good idea because plugins could cause infinite loops.
Let me know if you think this idea would be worth pursuing, I'll try implementing a simple poc.
Sorry for the silence on this one, I missed it in my inbox when you first posted it.
Here are a couple things I'd want to think about before expanding peru's plugin APIs:
- Copying code. Is it easy to just copy the code of the existing git plugin, and make changes in there to implement things like
gh_repo
? Currently our plugins don't actually share any code with each other, so each one should be pretty self-contained. - Shelling out to plugin files directly. If we exposed some functions from
peru/plugin.py
to make it easier to grab the path to a plugin executable, how would you feel about executing those directly from your own plugin code?