Skip to content

Commit 04b924f

Browse files
committed
Updates README
1 parent 5fd631e commit 04b924f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,36 @@ $ export MONGO_URL=mongodb://localhost:27017/lair
1010
$ export API_LISTENER=ip:port
1111
$ ./api-server
1212
```
13+
14+
## Transforms
15+
Transforms allow you to use Go plugins to modify a project that is sent as part of an update. Go plugins are Linux only and have been available since v1.8.
16+
17+
### Confguration
18+
The api-server will load all plugins from a directory that is set via the `TRANSFORM_DIR` environment variable. Example:
19+
```
20+
$ export TRANSFORM_DIR=plugins
21+
$ ls plugins
22+
iis.so foo.so bar.so
23+
$ ./api-server
24+
2017/03/03 12:56:05 Loading transform iis.so
25+
2017/03/03 12:56:05 Loading transform foo.so
26+
2017/03/03 12:56:05 Loading transform bar.so
27+
````
28+
29+
### Writing Transforms
30+
Writing transform involves implmenting a single function, `Update(p *lair.Project`. Here is a stub.
31+
```
32+
package main
33+
34+
import (
35+
lair "github.com/lair-framework/go-lair"
36+
)
37+
38+
func Update(p *lair.Project) {
39+
for i := range p.Hosts {
40+
p[i].Host.OS = "Trash"
41+
}
42+
}
43+
```
44+
45+
This can now be built by running `go build -buildmode=plugin`.

0 commit comments

Comments
 (0)