|
1 | 1 | # Plugins
|
2 | 2 |
|
3 |
| -Plugins allow users to extend Warnet. Plugin authors can import commands from Warnet and plugin users can run plugin commands from the command line or on each invocation of `warnet deploy`. |
| 3 | +Plugins extend Warnet. Plugin authors can import commands from Warnet and interact with the kubernetes cluster, and plugin users can run plugins from the command line or from the `network.yaml` file. |
4 | 4 |
|
5 |
| -## Activating plugins from 'network.yaml' |
| 5 | +## Activating plugins from `network.yaml` |
6 | 6 |
|
7 |
| -You can activate a plugin command by placing it in the `plugin` section at the bottom of each `network.yaml` file like so: |
| 7 | +You can activate a plugin command by placing it in the `plugins` section at the bottom of each `network.yaml` file like so: |
| 8 | + |
| 9 | +````yaml |
| 10 | +nodes: |
| 11 | + <<snip>> |
| 12 | + |
| 13 | +plugins: # This marks the beginning of the plugin section |
| 14 | + preDeploy: # This is a hook. This particular hook will call plugins before deploying anything else. |
| 15 | + hello: # This is the name of the plugin. |
| 16 | + entrypoint: "../plugins/hello" # Every plugin must specify a path to its entrypoint. |
| 17 | + podName: "hello-pre-deploy" # Plugins can have their own particular configurations, such as how to name a pod. |
| 18 | + helloTo: "preDeploy!" # This configuration tells the hello plugin who to say "hello" to. |
| 19 | +```` |
| 20 | + |
| 21 | +## Many kinds of hooks |
| 22 | +There are many hooks to the Warnet `deploy` command. The example below specifies them: |
8 | 23 |
|
9 | 24 | ````yaml
|
10 | 25 | nodes:
|
11 | 26 | <<snip>>
|
12 | 27 |
|
13 | 28 | plugins:
|
14 |
| - preDeploy: |
| 29 | + preDeploy: # Plugins will run before any other `deploy` code. |
15 | 30 | hello:
|
16 | 31 | entrypoint: "../plugins/hello"
|
17 | 32 | podName: "hello-pre-deploy"
|
18 | 33 | helloTo: "preDeploy!"
|
19 |
| - postDeploy: |
| 34 | + postDeploy: # Plugins will run after all the `deploy` code has run. |
20 | 35 | simln:
|
21 |
| - entrypoint: "../../../resources/plugins/simln" |
| 36 | + entrypoint: "../plugins/simln" |
22 | 37 | activity: '[{"source": "tank-0003-ln", "destination": "tank-0005-ln", "interval_secs": 1, "amount_msat": 2000}]'
|
23 | 38 | hello:
|
24 | 39 | entrypoint: "../plugins/hello"
|
25 | 40 | podName: "hello-post-deploy"
|
26 | 41 | helloTo: "postDeploy!"
|
27 |
| - preNode: |
| 42 | + preNode: # Plugins will run before `deploy` launches a node (once per node). |
28 | 43 | hello:
|
29 | 44 | entrypoint: "../plugins/hello"
|
30 | 45 | helloTo: "preNode!"
|
31 |
| - postNode: |
| 46 | + postNode: # Plugins will run after `deploy` launches a node (once per node). |
32 | 47 | hello:
|
33 | 48 | entrypoint: "../plugins/hello"
|
34 | 49 | helloTo: "postNode!"
|
35 |
| - preNetwork: |
| 50 | + preNetwork: # Plugins will run before `deploy` launches the network (essentially between logging and when nodes are deployed) |
36 | 51 | hello:
|
37 | 52 | entrypoint: "../plugins/hello"
|
38 | 53 | helloTo: "preNetwork!"
|
39 | 54 | podName: "hello-pre-network"
|
40 |
| - postNetwork: |
| 55 | + postNetwork: # Plugins will run after the network deploy threads have been joined. |
41 | 56 | hello:
|
42 | 57 | entrypoint: "../plugins/hello"
|
43 | 58 | helloTo: "postNetwork!"
|
44 | 59 | podName: "hello-post-network"
|
45 | 60 | ````
|
46 | 61 |
|
47 |
| -Warnet will execute these plugin commands after each invocation of `warnet deploy`. |
| 62 | +Warnet will execute these plugin commands during each invocation of `warnet deploy`. |
| 63 | + |
| 64 | + |
48 | 65 |
|
49 |
| -## Example: SimLN |
| 66 | +## A "hello" example |
50 | 67 |
|
51 |
| -To get started with an example plugin, review the `README` of the `simln` plugin found in any initialized Warnet directory: |
| 68 | +To get started with an example plugin, review the `README` of the `hello` plugin found in any initialized Warnet directory: |
52 | 69 |
|
53 | 70 | 1. `warnet init`
|
54 |
| -2. `cd plugins/simln/` |
| 71 | +2. `cd plugins/hello/` |
55 | 72 |
|
0 commit comments