Plugin system and "renderers" - #288
Conversation
13698c6 to
0ece687
Compare
Looking forward to this :-)
I would advise leaving this for later, in order to
To expand on 2., I will admit here to be very nervous about anything that looks like packaging and distribution, and anything that does automatic downloads. The first bout of nerves is that it will effectively determine how packaging works for everything to do with |
0ece687 to
9f926c0
Compare
| plugin(kind: string, url: string, input: JSON) -> JSON | ||
| ``` | ||
|
|
||
| - `kind` is the kind of plugin invoked (eg. `render`). Plugin binaries can |
There was a problem hiding this comment.
What does kind actually affect? I don't see it mentioned after here.
| `https://jkcfg.github.io/plugins/helm/0.1.0/plugin.json`. This JSON file is | ||
| really plugin metadata (see next section). It is highly recommended, for | ||
| reproducibility, to ensure the plugin definition and binaries the URL points | ||
| to be immutable to encode a version in the URL. |
| 1. Packaging. One goal is to be able to package all the dependencies needed | ||
| for a `jk` script to run. Having the plugin abstraction with metadata | ||
| allows that. | ||
|
|
There was a problem hiding this comment.
I reckon it's worth mentioning | here -- i.e., no plugins, just pipe the output of another command into jk (or write files and use them as input to jk, etc.). One of the problems I remember from our discussions of this is that you can't have more than one source of input via |; another (slightly harder to pin down) is that it's better to have control from within JavaScript code, so you can e.g., encapsulate the fact of the external tooling.
|
|
||
| For development purposes it is possible to point the `plugin` RPC call to a | ||
| local file by giving a relative path to the JSON plugin definition. The | ||
| `binaries` fields can point at plugins present in the `PATH`. |
There was a problem hiding this comment.
Another formulation of this would be to expect a relative path to the binary. This would make sense if the binaries are shipped with the code wrapping them, for example.
| VERSION := $(shell git describe --tags) | ||
|
|
||
| jk: pkg/__std/lib/assets_vfsdata.go FORCE | ||
| ifneq ($(RW),yes) |
There was a problem hiding this comment.
I'm guessing the motivation here is that occasionally it's a pain to have it not build because you've introduced a new dependency. You can just issue go mod tidy when that's the case.
Co-Authored-By: Michael Bridgen <mikeb@squaremobius.net>
Co-Authored-By: Michael Bridgen <mikeb@squaremobius.net>
Co-Authored-By: Michael Bridgen <mikeb@squaremobius.net>
Wouldn't it be nice if we could bring into
jkobjects from external sources? For instance we could render a helm chart, bring the result intojkas an array of objects, modify objects as we see fit and write the final result to files.This PR introduces plugins and the first type of plugins:
Renderer. ARenderertakes a js object as input and returns a js value. This PR includes a testEchoRendererplugin that simply outputs the input it receives.Plugins are identified by a json document with some metadata about the plugin, including where to find plugin binaries for the current OS/architecture.
echo.json
{ "name": "echo", "version": "0.1.0", "binaries": { "linux-amd64": "jk-plugin-echo" } }simple usage example
TODO:
Support downloading the plugin description and the plugin binaries from http URLsdecided not to do this.@jkcfg/kubernetes(helm plugin kubernetes#55)Updates: #133