peru icon indicating copy to clipboard operation
peru copied to clipboard

Implement a way to chain plugins

Open jck opened this issue 8 years ago • 1 comments

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 like buildinspace/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 a pre exe (which manipulates the environment) and a chain plug or pass plug or something which specifies the plugin which runs after the pre 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.

jck avatar Sep 02 '16 07:09 jck

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?

oconnor663 avatar Sep 26 '16 16:09 oconnor663