Skip to content

Commit 1fabfc4

Browse files
committed
chore: implement debug functionality with godump integration
- Add a new dependency on `github.com/yassinebenaid/godump` - Include `godump` in the import statements - Add a new environment variable `DEBUG` to the existing list - Implement a debug dump of the plugin if debugging is enabled Signed-off-by: appleboy <appleboy.tw@gmail.com>
1 parent 883f947 commit 1fabfc4

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/joho/godotenv v1.5.1
88
github.com/stretchr/testify v1.8.4
99
github.com/urfave/cli/v2 v2.27.5
10+
github.com/yassinebenaid/godump v0.11.1
1011
golang.org/x/crypto v0.29.0
1112
)
1213

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
2323
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
2424
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
2525
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
26+
github.com/yassinebenaid/godump v0.11.1 h1:SPujx/XaYqGDfmNh7JI3dOyCUVrG0bG2duhO3Eh2EhI=
27+
github.com/yassinebenaid/godump v0.11.1/go.mod h1:dc/0w8wmg6kVIvNGAzbKH1Oa54dXQx8SNKh4dPRyW44=
2628
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
2729
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
2830
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=

main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
easyssh "github.com/appleboy/easyssh-proxy"
1010
"github.com/joho/godotenv"
1111
"github.com/urfave/cli/v2"
12+
"github.com/yassinebenaid/godump"
1213
)
1314

1415
// Version set at compile-time
@@ -212,7 +213,7 @@ func main() {
212213
&cli.BoolFlag{
213214
Name: "debug",
214215
Usage: "debug mode",
215-
EnvVars: []string{"PLUGIN_DEBUG", "INPUT_DEBUG"},
216+
EnvVars: []string{"PLUGIN_DEBUG", "INPUT_DEBUG", "DEBUG"},
216217
},
217218
&cli.StringFlag{
218219
Name: "envs.format",
@@ -329,5 +330,9 @@ func run(c *cli.Context) error {
329330
Writer: os.Stdout,
330331
}
331332

333+
if plugin.Config.Debug {
334+
_ = godump.Dump(plugin)
335+
}
336+
332337
return plugin.Exec()
333338
}

0 commit comments

Comments
 (0)