From e3f4284781ccdce3e1e0ae85db4e3f0a8ae8bab5 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 24 Apr 2025 06:44:11 +0000 Subject: [PATCH] Bump urfave/cli to v3.2.0 (#49) Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/49 Reviewed-by: Patrick Schratz Co-authored-by: Robert Kaussow Co-committed-by: Robert Kaussow --- go.mod | 2 +- go.sum | 4 ++-- metadata_test.go | 2 +- pipeline.go | 20 ++++++++++---------- plugin.go | 8 ++++---- plugin_test.go | 2 +- step.go | 10 +++++----- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index a2b16d2..f57ea90 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/joho/godotenv v1.5.1 github.com/rs/zerolog v1.34.0 github.com/stretchr/testify v1.10.0 - github.com/urfave/cli/v3 v3.1.1 + github.com/urfave/cli/v3 v3.2.0 golang.org/x/net v0.38.0 ) diff --git a/go.sum b/go.sum index 6481b42..f8e0da2 100644 --- a/go.sum +++ b/go.sum @@ -17,8 +17,8 @@ github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY= github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/urfave/cli/v3 v3.1.1 h1:bNnl8pFI5dxPOjeONvFCDFoECLQsceDG4ejahs4Jtxk= -github.com/urfave/cli/v3 v3.1.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo= +github.com/urfave/cli/v3 v3.2.0 h1:m8WIXY0U9LCuUl5r+0fqLWDhNYWt6qvlW+GcF4EoXf8= +github.com/urfave/cli/v3 v3.2.0/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/metadata_test.go b/metadata_test.go index 27ad758..ef1f123 100644 --- a/metadata_test.go +++ b/metadata_test.go @@ -78,7 +78,7 @@ func TestMetadata(t *testing.T) { return nil }, }) - err := plugin.app.Run(plugin.ctx, []string{"test"}) + err := plugin.App.Run(plugin.ctx, []string{"test"}) require.NoError(t, err) // Repository diff --git a/pipeline.go b/pipeline.go index 4166c9f..7ad5350 100644 --- a/pipeline.go +++ b/pipeline.go @@ -51,7 +51,7 @@ type Pipeline struct { func pipelineFlags() []cli.Flag { return []cli.Flag{ - &cli.IntFlag{ + &cli.Int64Flag{ Name: "pipeline.number", Usage: "pipeline number", Sources: cli.EnvVars( @@ -93,7 +93,7 @@ func pipelineFlags() []cli.Flag { "DRONE_DEPLOY_TO", ), }, - &cli.IntFlag{ + &cli.Int64Flag{ Name: "pipeline.created", Usage: "pipeline creation time", Sources: cli.EnvVars( @@ -101,7 +101,7 @@ func pipelineFlags() []cli.Flag { "DRONE_BUILD_CREATED", ), }, - &cli.IntFlag{ + &cli.Int64Flag{ Name: "pipeline.started", Usage: "pipeline start time", Sources: cli.EnvVars( @@ -109,7 +109,7 @@ func pipelineFlags() []cli.Flag { "DRONE_BUILD_STARTED", ), }, - &cli.IntFlag{ + &cli.Int64Flag{ Name: "pipeline.finished", Usage: "pipeline finish time", Sources: cli.EnvVars( @@ -117,7 +117,7 @@ func pipelineFlags() []cli.Flag { "DRONE_BUILD_FINISHED", ), }, - &cli.IntFlag{ + &cli.Int64Flag{ Name: "pipeline.parent", Usage: "pipeline parent", Sources: cli.EnvVars( @@ -146,16 +146,16 @@ func pipelineFromContext(c *cli.Command) Pipeline { } return Pipeline{ - Number: c.Int("pipeline.number"), + Number: c.Int64("pipeline.number"), Status: c.String("pipeline.status"), Event: c.String("pipeline.event"), URL: c.String("pipeline.url"), Link: c.String("pipeline.url"), DeployTarget: c.String("pipeline.deploy-target"), - Created: time.Unix(c.Int("pipeline.created"), 0), - Started: time.Unix(c.Int("pipeline.started"), 0), - Finished: time.Unix(c.Int("pipeline.finished"), 0), - Parent: c.Int("pipeline.parent"), + Created: time.Unix(c.Int64("pipeline.created"), 0), + Started: time.Unix(c.Int64("pipeline.started"), 0), + Finished: time.Unix(c.Int64("pipeline.finished"), 0), + Parent: c.Int64("pipeline.parent"), ChangedFiles: changedFiles, } } diff --git a/plugin.go b/plugin.go index dd64f05..ea2d800 100644 --- a/plugin.go +++ b/plugin.go @@ -42,7 +42,7 @@ type Options struct { // Plugin defines the plugin instance. type Plugin struct { - app *cli.Command + App *cli.Command execute ExecuteFunc client *http.Client ctx context.Context @@ -68,11 +68,11 @@ func New(opt Options) *Plugin { } plugin := &Plugin{ - app: app, + App: app, execute: opt.Execute, ctx: opt.Context, } - plugin.app.Action = plugin.action + plugin.App.Action = plugin.action if plugin.ctx == nil { plugin.ctx = context.Background() @@ -103,7 +103,7 @@ func (p *Plugin) HTTPClient() *http.Client { // Run the plugin. func (p *Plugin) Run() { - if err := p.app.Run(p.ctx, os.Args); err != nil { + if err := p.App.Run(p.ctx, os.Args); err != nil { log.Error().Err(err).Msg("execution failed") os.Exit(1) } diff --git a/plugin_test.go b/plugin_test.go index b99626b..036fbd4 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -30,7 +30,7 @@ func TestPlugin(t *testing.T) { return nil }, }) - err := p.app.Run(p.ctx, []string{"test"}) + err := p.App.Run(p.ctx, []string{"test"}) assert.NoError(t, err) assert.True(t, executed) } diff --git a/step.go b/step.go index 51f2b31..e50e7c7 100644 --- a/step.go +++ b/step.go @@ -37,14 +37,14 @@ func stepFlags() []cli.Flag { "DRONE_STEP_NUMBER", ), }, - &cli.IntFlag{ + &cli.Int64Flag{ Name: "step.started", Usage: "step start time", Sources: cli.EnvVars( "CI_STEP_STARTED", ), }, - &cli.IntFlag{ + &cli.Int64Flag{ Name: "step.finished", Usage: "step finish time", Sources: cli.EnvVars( @@ -56,8 +56,8 @@ func stepFlags() []cli.Flag { func stepFromContext(c *cli.Command) Step { return Step{ - Number: int(c.Int("step.number")), - Started: time.Unix(c.Int("step.started"), 0), - Finished: time.Unix(c.Int("step.finished"), 0), + Number: c.Int("step.number"), + Started: time.Unix(c.Int64("step.started"), 0), + Finished: time.Unix(c.Int64("step.finished"), 0), } }