Skip to content
This repository was archived by the owner on May 14, 2022. It is now read-only.

Commit 355437f

Browse files
committed
feat: add TriggerHook
1 parent 1e5a4a2 commit 355437f

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

README.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ import "github.com/getstackhead/pluginlib"
1010
type MyPlugin struct {
1111
}
1212

13+
var PluginConfig = pluginlib.PluginConfig{
14+
Name: "Test",
15+
Description: "This is an example StackHead Proxy plugin",
16+
Version: "0.0.0-dev",
17+
Authors: []string{"Your Name"},
18+
PluginType: pluginlib.PluginType.PROXY,
19+
}
20+
1321
func (p MyPlugin) Setup() {
1422
// implement software setup action
1523
}
@@ -22,14 +30,14 @@ func (p MyPlugin) Destroy(project pluginlib.Project) {
2230
// implement project destroy action
2331
}
2432

25-
func (p MyPlugin) HookPreTerraformPlan(project pluginlib.Project) {
26-
// pre terraform plan hook (to be implemented)
33+
func (p MyPlugin) TriggerHook(hookName string, project pluginlib.Project) {
34+
// triggered by hooks
2735
}
2836

2937
// Export plugin to StackHead. Must be named "Plugin"!
3038
var Plugin MyPlugin
3139
```
3240

3341
```shell
34-
go build -buildmode=plugin -o plugin_myplugin.so main.go
42+
go build -buildmode=plugin -o plugin.so main.go
3543
```

example/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ func (p MyPlugin) Destroy(project pluginlib.Project) {
2929
func (p MyPlugin) Setup() {
3030
fmt.Println("Setup...")
3131
}
32+
33+
func (p MyPlugin) TriggerHook(hookName string, project pluginlib.Project) {
34+
fmt.Println("Hook " + hookName + " triggered for project " + project.Name + ".")
35+
}
Binary file not shown.

plugin.go

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type Plugin interface {
88
Setup()
99
Deploy(project Project)
1010
Destroy(project Project)
11+
TriggerHook(hookName string, project Project)
1112
}
1213

1314
func LoadPlugin(path string) (Plugin, *PluginConfig, error) {

0 commit comments

Comments
 (0)