From cddf245c12223c783c856c87c21cc796ac425439 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 15 Oct 2023 23:46:06 +0800 Subject: Replace more db.DefaultContext (#27628) Target #27065 --- contrib/fixtures/fixture_generation.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'contrib') diff --git a/contrib/fixtures/fixture_generation.go b/contrib/fixtures/fixture_generation.go index 06c0354efa..31797cc800 100644 --- a/contrib/fixtures/fixture_generation.go +++ b/contrib/fixtures/fixture_generation.go @@ -5,6 +5,7 @@ package main import ( + "context" "fmt" "os" "path/filepath" @@ -18,7 +19,7 @@ import ( var ( generators = []struct { - gen func() (string, error) + gen func(ctx context.Context) (string, error) name string }{ { @@ -41,16 +42,17 @@ func main() { fmt.Printf("PrepareTestDatabase: %+v\n", err) os.Exit(1) } + ctx := context.Background() if len(os.Args) == 0 { for _, r := range os.Args { - if err := generate(r); err != nil { + if err := generate(ctx, r); err != nil { fmt.Printf("generate '%s': %+v\n", r, err) os.Exit(1) } } } else { for _, g := range generators { - if err := generate(g.name); err != nil { + if err := generate(ctx, g.name); err != nil { fmt.Printf("generate '%s': %+v\n", g.name, err) os.Exit(1) } @@ -58,10 +60,10 @@ func main() { } } -func generate(name string) error { +func generate(ctx context.Context, name string) error { for _, g := range generators { if g.name == name { - data, err := g.gen() + data, err := g.gen(ctx) if err != nil { return err } -- cgit v1.2.3