diff --git a/README.md b/README.md index a417195..9876805 100644 --- a/README.md +++ b/README.md @@ -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 } @@ -22,8 +30,8 @@ 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"! @@ -31,5 +39,5 @@ var Plugin MyPlugin ``` ```shell -go build -buildmode=plugin -o plugin_myplugin.so main.go +go build -buildmode=plugin -o plugin.so main.go ``` diff --git a/example/main.go b/example/main.go index c911d8c..2265a17 100644 --- a/example/main.go +++ b/example/main.go @@ -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 + ".") +} diff --git a/example/plugin_myplugin.so b/example/plugin.so similarity index 53% rename from example/plugin_myplugin.so rename to example/plugin.so index c9818a2..b13bf57 100644 Binary files a/example/plugin_myplugin.so and b/example/plugin.so differ diff --git a/plugin.go b/plugin.go index 84e1629..7278303 100644 --- a/plugin.go +++ b/plugin.go @@ -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) {