Compare commits

...

2 commits

3 changed files with 53 additions and 0 deletions

View file

@ -199,6 +199,12 @@ makeshift plugins compile src/example.go -o $MAKESHIFT_ROOT/plugins/example.so
> [!TIP]
> Make sure you move all of your plugins to `$MAKESHIFT_ROOT/plugins` to use them and should have an `*.so` name for lookup. For example, to use a custom plugin with `makeshift download -p templates/hosts.j2 --plugins my-plugin`, there has to a plugin `$MAKESHIFT_ROOT/plugins/my-plugin.so`.
### Built-in Plugins
There is a collection of built-in plugins that can be compiled using the helper script in `bin/compile-plugins.so` and saved to `$MAKESHIFT_ROOT/plugins`.
See the README for [`jinja`](pkg/plugins/jinja2/README.md) and [`smd`](pkg/plugins/smd/README.md) for more details.
## Creating Profiles
On the other hand, profiles are simply objects that contain data used to populate data stores. The `makeshift` tool does not currently use all fields of a profile which will likely be removed in the near future.

View file

@ -0,0 +1,34 @@
# Makeshift Jinja 2 Plugin
This is a `makeshift` plugin that allows rendering files with Jinja 2 grammar. The plugin reads from a `storage.KVStore` passed to the `Run()` function and substitute the values in files provided with key `file`. Profiles can also be used to inject data into the store as well.
Compile the plugin if not done already.
```bash
makeshift compile pkg/plugins/jinja2/jinja2.go -o $MAKESHIFT_ROOT/plugins/jinja.so
```
Then, try download a file that contains Jinja2 variables. The `makeshift` server includes a `help.txt` and `default.json` profile to show how rendering can be done with downloads, profiles, and plugins.
First, try downloading the `help.txt` file *without* rendering.
```bash
makeshift download -p help.txt
```
Notice that there are Jinja2 variables with no substitutions done here. Now, try it again with the `jinja2` plugin and the `default` profile.
```bash
makeshift download -p help.txt --plugins jinja2 --profile default
```
You should see the same file, but now the values are populated with the content stored in the profile. Remember...the data can also be populated using other plugins as well (see the [`smd`](../smd/README.md) plugin regarding this).
Also, keep in mind that rendering happens across directories as well.
```bash
makeshift download -p templates --plugins jinja2 --profile
default
```
This will render all Jinja 2 templates before archiving and downloading the files with the client.

13
pkg/plugins/smd/README.md Normal file
View file

@ -0,0 +1,13 @@
# Makeshift SMD Plugin
This `makeshift` plugin fetchs data from [SMD](https://github.com/OpenCHAMI/smd) and stores it in the `storage.KVStore` passed to the `Run()` function. This plugin can be used in conjunction with other plugins like the `jinja2` plugin to render files using the data stored.
Here's a simple example.
```bash
makeshift download -p /etc/hosts --plugins smd,jinja2 -xr
```
This example downloads all the files in the `/etc/hosts` directory and renders the Jinja 2 templates with the data fetched from SMD. Then, the `-x` and `-r` flags tells the CLI to extract and remove the archive respectively.
Since plugins are ran in the order specified with the CLI, be sure to always call the `smd` plugin before reading from the `storage.KVStore` like in the example above or else the fetched data will not exist!