MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / RetryWithRefreshedResource

Function RetryWithRefreshedResource

pkg/resources/retry.go:33–46  ·  view source on GitHub ↗

RetryWithRefreshedResource updates the resource before invoking the cb

(
	ctx context.Context,
	cli client.Client,
	resource client.Object,
	cb func() error,
)

Source from the content-addressed store, hash-verified

31
32// RetryWithRefreshedResource updates the resource before invoking the cb
33func RetryWithRefreshedResource(
34 ctx context.Context,
35 cli client.Client,
36 resource client.Object,
37 cb func() error,
38) error {
39 return retry.OnError(retry.DefaultBackoff, RetryAlways, func() error {
40 if err := cli.Get(ctx, client.ObjectKeyFromObject(resource), resource); err != nil {
41 return err
42 }
43
44 return cb()
45 })
46}

Callers 3

retry_test.goFile · 0.85

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected