Skip to content

Commit 7e81677

Browse files
chore(deps): update module github.com/cenkalti/backoff/v4 to v5 (#1115)
* chore(deps): update module github.com/cenkalti/backoff/v4 to v5 * chore: port to backoff v5 There are a few relatively minor API changes to adapt to in backoff v5. Here we fix them all. --------- Co-authored-by: renovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com> Co-authored-by: Iain Lane <[email protected]>
1 parent e0f62e4 commit 7e81677

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

actions/trigger-argo-workflow/cmd/trigger-argo-workflow/argo.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"bufio"
5+
"context"
56
"fmt"
67
"io"
78
"log/slog"
@@ -11,7 +12,7 @@ import (
1112
"strings"
1213
"time"
1314

14-
"github.com/cenkalti/backoff/v4"
15+
"github.com/cenkalti/backoff/v5"
1516
)
1617

1718
type App struct {
@@ -165,26 +166,26 @@ func isFatalError(err error) bool {
165166
return false
166167
}
167168

168-
func (a *App) Run(md GitHubActionsMetadata) error {
169-
bo := backoff.WithMaxRetries(backoff.NewExponentialBackOff(), a.retries)
169+
func (a *App) Run(ctx context.Context, md GitHubActionsMetadata) error {
170+
bo := backoff.NewExponentialBackOff()
170171

171-
var uri string
172172
var out string
173173

174-
run := func() error {
174+
run := func() (string, error) {
175+
var uri string
175176
var err error
176177
uri, out, err = a.runCmd(md)
177178

178179
if isFatalError(err) {
179-
return backoff.Permanent(err)
180+
return uri, backoff.Permanent(err)
180181
}
181182

182-
return err
183+
return uri, err
183184
}
184185

185-
err := backoff.RetryNotify(run, bo, func(err error, t time.Duration) {
186+
uri, err := backoff.Retry(ctx, run, backoff.WithBackOff(bo), backoff.WithMaxTries(uint(a.retries)), backoff.WithNotify(func(err error, t time.Duration) {
186187
a.logger.With("error", err, "retry_in", t).Error("failed to run command, retrying")
187-
})
188+
}))
188189
if err != nil {
189190
return err
190191
}

actions/trigger-argo-workflow/cmd/trigger-argo-workflow/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,5 @@ func run(c *cli.Context, level *slog.LevelVar, logger *slog.Logger) error {
212212
retries: retries,
213213
}
214214

215-
return argo.Run(md)
215+
return argo.Run(c.Context, md)
216216
}

actions/trigger-argo-workflow/go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ module github.com/grafana/shared-workflows/actions/trigger-argo-workflow
33
go 1.23.1
44

55
require (
6-
github.com/cenkalti/backoff/v4 v4.3.0
76
github.com/cenkalti/backoff/v5 v5.0.2
87
github.com/kelseyhightower/envconfig v1.4.0
98
github.com/lmittmann/tint v1.1.2
109
github.com/stretchr/testify v1.10.0
1110
github.com/urfave/cli/v2 v2.27.7
12-
github.com/urfave/cli/v3 v3.3.8
1311
github.com/willabides/actionslog v0.5.1
1412
golang.org/x/term v0.32.0
1513
)

actions/trigger-argo-workflow/go.sum

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
2-
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
1+
github.com/cenkalti/backoff/v5 v5.0.2 h1:rIfFVxEf1QsI7E1ZHfp/B4DF/6QBAUhmgkxc0H7Zss8=
32
github.com/cenkalti/backoff/v5 v5.0.2/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
43
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
54
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
@@ -35,7 +34,6 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
3534
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
3635
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
3736
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
38-
github.com/urfave/cli/v3 v3.3.8/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo=
3937
github.com/willabides/actionslog v0.5.1 h1:dJ/Cxg8vO1pEohgC2O4CW1tCWFKJrYJXTZDWYJQK0+E=
4038
github.com/willabides/actionslog v0.5.1/go.mod h1:WDufDP3XZUMBOmau2BvfVCGYuUcVRZI6Eqy8ZRw4pJ8=
4139
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=

0 commit comments

Comments
 (0)