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

Commit

Permalink
feat: add TriggerHook
Browse files Browse the repository at this point in the history
  • Loading branch information
saitho committed Sep 26, 2021
1 parent 1e5a4a2 commit 355437f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import "github.com/getstackhead/pluginlib"
type MyPlugin struct {
}

var PluginConfig = pluginlib.PluginConfig{
Name: "Test",
Description: "This is an example StackHead Proxy plugin",
Version: "0.0.0-dev",
Authors: []string{"Your Name"},
PluginType: pluginlib.PluginType.PROXY,
}

func (p MyPlugin) Setup() {
// implement software setup action
}
Expand All @@ -22,14 +30,14 @@ func (p MyPlugin) Destroy(project pluginlib.Project) {
// implement project destroy action
}

func (p MyPlugin) HookPreTerraformPlan(project pluginlib.Project) {
// pre terraform plan hook (to be implemented)
func (p MyPlugin) TriggerHook(hookName string, project pluginlib.Project) {
// triggered by hooks
}

// Export plugin to StackHead. Must be named "Plugin"!
var Plugin MyPlugin
```

```shell
go build -buildmode=plugin -o plugin_myplugin.so main.go
go build -buildmode=plugin -o plugin.so main.go
```
4 changes: 4 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ func (p MyPlugin) Destroy(project pluginlib.Project) {
func (p MyPlugin) Setup() {
fmt.Println("Setup...")
}

func (p MyPlugin) TriggerHook(hookName string, project pluginlib.Project) {
fmt.Println("Hook " + hookName + " triggered for project " + project.Name + ".")
}
Binary file renamed example/plugin_myplugin.so → example/plugin.so
Binary file not shown.
1 change: 1 addition & 0 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type Plugin interface {
Setup()
Deploy(project Project)
Destroy(project Project)
TriggerHook(hookName string, project Project)
}

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

0 comments on commit 355437f

Please sign in to comment.