This repository was archived by the owner on May 14, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +57
-0
lines changed Expand file tree Collapse file tree 5 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ module github/getstackhead/pluginlib/example
2+
3+ go 1.17
4+
5+ require github.com/getstackhead/pluginlib v0.0.0
6+
7+ replace github.com/getstackhead/pluginlib => ../
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import "fmt"
4+ import "github.com/getstackhead/pluginlib"
5+
6+ type MyPlugin struct {
7+ }
8+
9+ func (p MyPlugin ) GetConfig () pluginlib.PluginConfig {
10+ return pluginlib.PluginConfig {
11+ Name : "Test" ,
12+ Description : "This is an example StackHead Proxy plugin" ,
13+ Version : "0.0.0-dev" ,
14+ Author : "Mario Lubenka" ,
15+ PluginType : pluginlib .PluginType .PROXY ,
16+ }
17+ }
18+
19+ func (p MyPlugin ) Deploy (project pluginlib.Project ) {
20+ fmt .Println ("Hello " + project .Name )
21+ }
22+
23+ func (p MyPlugin ) Destroy (project pluginlib.Project ) {
24+ fmt .Println ("Bye " + project .Name )
25+ }
26+
27+ func (p MyPlugin ) Setup () {
28+ fmt .Println ("Setup..." )
29+ }
30+
31+ var Plugin MyPlugin
Original file line number Diff line number Diff line change 1+ package main_test
2+
3+ import (
4+ "testing"
5+
6+ "github.com/getstackhead/pluginlib"
7+ )
8+
9+ func TestPluginLoading (t * testing.T ) {
10+ loadedPlugin , err := pluginlib .LoadPlugin ("./plugin_myplugin.so" )
11+ if err != nil {
12+ t .Fatal ("Unable to load plugin. Error occurred: " + err .Error ())
13+ return
14+ }
15+ if loadedPlugin == nil {
16+ t .Fatal ("Unable to load plugin. Plugin is nil" )
17+ return
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments