From 76f5076b0a5ad5442091234fcc1805881363fe62 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Fri, 17 May 2024 21:50:20 +0200 Subject: [PATCH] chore: migrate to wp-plugin-go v3 (#116) --- go.mod | 2 +- go.sum | 4 ++-- internal/doc/main.go | 6 +++--- plugin/impl.go | 4 ++-- plugin/impl_test.go | 14 +++++++------- plugin/plugin.go | 12 ++++++------ 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index d00765a..bedd9a8 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/microcosm-cc/bluemonday v1.0.26 github.com/rs/zerolog v1.32.0 github.com/stretchr/testify v1.9.0 - github.com/thegeeklab/wp-plugin-go/v2 v2.3.1 + github.com/thegeeklab/wp-plugin-go/v3 v3.0.2 github.com/urfave/cli/v2 v2.27.2 maunium.net/go/mautrix v0.18.1 ) diff --git a/go.sum b/go.sum index e89dd83..068273d 100644 --- a/go.sum +++ b/go.sum @@ -60,8 +60,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/thegeeklab/wp-plugin-go/v2 v2.3.1 h1:ARwYgTPZ5iPsmOenmqcCf8TjiEe8wBOHKO7H/Xshe48= -github.com/thegeeklab/wp-plugin-go/v2 v2.3.1/go.mod h1:0t8M8txtEFiaB6RqLX8vLrxkqAo5FT5Hx7dztN592D4= +github.com/thegeeklab/wp-plugin-go/v3 v3.0.2 h1:Mv5i8S1WY+BUNjTjX6lOnB3p8S9mvM+XwfY4R98gx0g= +github.com/thegeeklab/wp-plugin-go/v3 v3.0.2/go.mod h1:ij1iJcAVgzerBTqXnmq0bu1VA+hhVVwzXKqiqfoGjjg= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= diff --git a/internal/doc/main.go b/internal/doc/main.go index 02c3dd9..13eebea 100644 --- a/internal/doc/main.go +++ b/internal/doc/main.go @@ -11,8 +11,8 @@ import ( "time" "github.com/thegeeklab/wp-matrix/plugin" - "github.com/thegeeklab/wp-plugin-go/v2/docs" - "github.com/thegeeklab/wp-plugin-go/v2/template" + plugin_docs "github.com/thegeeklab/wp-plugin-go/v3/docs" + plugin_template "github.com/thegeeklab/wp-plugin-go/v3/template" ) func main() { @@ -23,7 +23,7 @@ func main() { p := plugin.New(nil) - out, err := template.Render(context.Background(), client, tmpl, docs.GetTemplateData(p.App)) + out, err := plugin_template.Render(context.Background(), client, tmpl, plugin_docs.GetTemplateData(p.App)) if err != nil { panic(err) } diff --git a/plugin/impl.go b/plugin/impl.go index 7accc74..49b0648 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -13,7 +13,7 @@ import ( "github.com/rs/zerolog/log" "github.com/thegeeklab/wp-matrix/matrix" - "github.com/thegeeklab/wp-plugin-go/v2/template" + plugin_template "github.com/thegeeklab/wp-plugin-go/v3/template" ) var ErrAuthSourceNotSet = errors.New("either username and password or userid and accesstoken are required") @@ -78,5 +78,5 @@ func (p *Plugin) Execute() error { // CreateMessage generates a message string based on the plugin's template and metadata. func (p *Plugin) CreateMessage() (string, error) { - return template.RenderTrim(p.Network.Context, *p.Network.Client, p.Settings.Template, p.Metadata) + return plugin_template.RenderTrim(p.Network.Context, *p.Network.Client, p.Settings.Template, p.Metadata) } diff --git a/plugin/impl_test.go b/plugin/impl_test.go index 9d8f444..11aba57 100644 --- a/plugin/impl_test.go +++ b/plugin/impl_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - wp "github.com/thegeeklab/wp-plugin-go/v2/plugin" + plugin_base "github.com/thegeeklab/wp-plugin-go/v3/plugin" ) func Test_messageContent(t *testing.T) { @@ -29,24 +29,24 @@ func Test_messageContent(t *testing.T) { } p := New(func(_ context.Context) error { return nil }) - p.Network = wp.Network{ + p.Network = plugin_base.Network{ Context: context.Background(), Client: &http.Client{}, } - p.Metadata = wp.Metadata{ - Curr: wp.Commit{ + p.Metadata = plugin_base.Metadata{ + Curr: plugin_base.Commit{ Branch: "main", Title: "feat: demo commit title", URL: "https://git.example.com", - Author: wp.Author{ + Author: plugin_base.Author{ Name: "octobot", }, }, - Pipeline: wp.Pipeline{ + Pipeline: plugin_base.Pipeline{ Status: "success", URL: "https://ci.example.com", }, - Repository: wp.Repository{ + Repository: plugin_base.Repository{ Slug: "octocat/demo", }, } diff --git a/plugin/plugin.go b/plugin/plugin.go index de5a3a1..8367dbe 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -9,7 +9,7 @@ package plugin import ( "fmt" - wp "github.com/thegeeklab/wp-plugin-go/v2/plugin" + plugin_base "github.com/thegeeklab/wp-plugin-go/v3/plugin" "github.com/urfave/cli/v2" ) @@ -24,7 +24,7 @@ Message: {{ .Curr.Title }}{{ if .Curr.URL }} ([source]({{ .Curr.URL }})){{ end } // Plugin implements provide the plugin. type Plugin struct { - *wp.Plugin + *plugin_base.Plugin Settings *Settings } @@ -40,15 +40,15 @@ type Settings struct { TemplateUnsafe bool } -func New(e wp.ExecuteFunc, build ...string) *Plugin { +func New(e plugin_base.ExecuteFunc, build ...string) *Plugin { p := &Plugin{ Settings: &Settings{}, } - options := wp.Options{ + options := plugin_base.Options{ Name: "wp-matrix", Description: "Send messages to a Matrix room", - Flags: Flags(p.Settings, wp.FlagsPluginCategory), + Flags: Flags(p.Settings, plugin_base.FlagsPluginCategory), Execute: p.run, HideWoodpeckerFlags: true, } @@ -65,7 +65,7 @@ func New(e wp.ExecuteFunc, build ...string) *Plugin { options.Execute = e } - p.Plugin = wp.New(options) + p.Plugin = plugin_base.New(options) return p }