From 60597e5ea75a9d55559529565afcfe05c2271082 Mon Sep 17 00:00:00 2001 From: justinsb Date: Fri, 5 Apr 2024 11:49:43 -0400 Subject: [PATCH] chore: fix go vet error in tests This looks like it is now a blocker in 1.22.2 (?) --- config/tests/samples/create/harness.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/config/tests/samples/create/harness.go b/config/tests/samples/create/harness.go index 7e7cfc2a45f..453cdbc6074 100644 --- a/config/tests/samples/create/harness.go +++ b/config/tests/samples/create/harness.go @@ -16,6 +16,8 @@ package create import ( "context" + "errors" + "fmt" "net/http" "os" "path/filepath" @@ -237,19 +239,28 @@ func NewHarnessWithOptions(ctx context.Context, t *testing.T, opts *HarnessOptio } { var wg sync.WaitGroup + var errsMutex sync.Mutex + var errs []error + for i := range crds { crd := &crds[i] wg.Add(1) log.V(2).Info("loading crd", "name", crd.GetName()) + go func() { defer wg.Done() if err := h.client.Create(ctx, crd.DeepCopy()); err != nil { - h.Fatalf("error creating crd %v: %v", crd.GroupVersionKind(), err) + errsMutex.Lock() + defer errsMutex.Unlock() + errs = append(errs, fmt.Errorf("error creating crd %v: %w", crd.GroupVersionKind(), err)) } h.waitForCRDReady(crd) }() } wg.Wait() + if len(errs) != 0 { + h.Fatalf("error creating crds: %v", errors.Join(errs...)) + } } }