From 627c1e9c607b3da92b809f9e6a5c244447c652fa Mon Sep 17 00:00:00 2001 From: bnkai <48220860+bnkai@users.noreply.github.com> Date: Thu, 24 Mar 2022 02:03:32 +0200 Subject: [PATCH] Fix plugin go examples (#2396) --- pkg/plugin/examples/common/graphql.go | 4 ++-- pkg/plugin/examples/goraw/main.go | 7 ++++--- pkg/plugin/examples/gorpc/main.go | 6 ++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/plugin/examples/common/graphql.go b/pkg/plugin/examples/common/graphql.go index fc045b3b8..8650758a8 100644 --- a/pkg/plugin/examples/common/graphql.go +++ b/pkg/plugin/examples/common/graphql.go @@ -29,8 +29,8 @@ type TagDestroyInput struct { type FindScenesResultType struct { Count graphql.Int - DurationSeconds graphql.Float - FilesizeBytes graphql.Int + DurationSeconds graphql.Float `graphql:"duration" json:"duration"` + FilesizeBytes graphql.Float `graphql:"filesize" json:"filesize"` Scenes []Scene } diff --git a/pkg/plugin/examples/goraw/main.go b/pkg/plugin/examples/goraw/main.go index c3b287bb4..98a20c850 100644 --- a/pkg/plugin/examples/goraw/main.go +++ b/pkg/plugin/examples/goraw/main.go @@ -4,6 +4,7 @@ package main import ( + "context" "encoding/json" "io" "os" @@ -54,14 +55,14 @@ func main() { func Run(input common.PluginInput, output *common.PluginOutput) error { modeArg := input.Args.String("mode") - + ctx := context.TODO() var err error if modeArg == "" || modeArg == "add" { client := util.NewClient(input.ServerConnection) - err = exampleCommon.AddTag(client) + err = exampleCommon.AddTag(ctx, client) } else if modeArg == "remove" { client := util.NewClient(input.ServerConnection) - err = exampleCommon.RemoveTag(client) + err = exampleCommon.RemoveTag(ctx, client) } else if modeArg == "long" { err = doLongTask() } else if modeArg == "indef" { diff --git a/pkg/plugin/examples/gorpc/main.go b/pkg/plugin/examples/gorpc/main.go index 1a86131cc..656f2c36f 100644 --- a/pkg/plugin/examples/gorpc/main.go +++ b/pkg/plugin/examples/gorpc/main.go @@ -4,6 +4,7 @@ package main import ( + "context" "time" exampleCommon "github.com/stashapp/stash/pkg/plugin/examples/common" @@ -37,14 +38,15 @@ func (a *api) Stop(input struct{}, output *bool) error { // acts accordingly. func (a *api) Run(input common.PluginInput, output *common.PluginOutput) error { modeArg := input.Args.String("mode") + ctx := context.TODO() var err error if modeArg == "" || modeArg == "add" { client := util.NewClient(input.ServerConnection) - err = exampleCommon.AddTag(client) + err = exampleCommon.AddTag(ctx, client) } else if modeArg == "remove" { client := util.NewClient(input.ServerConnection) - err = exampleCommon.RemoveTag(client) + err = exampleCommon.RemoveTag(ctx, client) } else if modeArg == "long" { err = a.doLongTask() } else if modeArg == "indef" {