From 6ad7079dff9a3eff14ee80d2e62db642b830250f Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Wed, 27 Nov 2024 12:49:24 +0000 Subject: [PATCH] Fix golangci-lint contextcheck error Signed-off-by: Richard Wall --- pkg/agent/config_test.go | 2 +- pkg/client/client_venconn_test.go | 2 +- pkg/testutil/envtest.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/agent/config_test.go b/pkg/agent/config_test.go index d826a9c5..bd466eb8 100644 --- a/pkg/agent/config_test.go +++ b/pkg/agent/config_test.go @@ -750,7 +750,7 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) { withCmdLineFlags("--venafi-connection", "venafi-components", "--install-namespace", "venafi")) require.NoError(t, err) - testutil.VenConnStartWatching(t, cl) + testutil.VenConnStartWatching(ctx, t, cl) testutil.TrustCA(t, cl, cert) // TODO(mael): the client should keep track of the cluster ID, we diff --git a/pkg/client/client_venconn_test.go b/pkg/client/client_venconn_test.go index 5dd48e6b..91e50edd 100644 --- a/pkg/client/client_venconn_test.go +++ b/pkg/client/client_venconn_test.go @@ -256,7 +256,7 @@ func run_TestVenConnClient_PostDataReadingsWithOptions(ctx context.Context, rest ) require.NoError(t, err) - testutil.VenConnStartWatching(t, cl) + testutil.VenConnStartWatching(ctx, t, cl) test.given = strings.ReplaceAll(test.given, "FAKE_VENAFI_CLOUD_URL", fakeVenafiCloud.URL) test.given = strings.ReplaceAll(test.given, "FAKE_TPP_URL", fakeTPP.URL) diff --git a/pkg/testutil/envtest.go b/pkg/testutil/envtest.go index cd93b4a6..e8d5f4e6 100644 --- a/pkg/testutil/envtest.go +++ b/pkg/testutil/envtest.go @@ -106,7 +106,7 @@ func WithKubeconfig(t testing.TB, restCfg *rest.Config) string { // Tests calling to VenConnClient.PostDataReadingsWithOptions must call this // function to start the VenafiConnection watcher. If you don't call this, the // test will stall. -func VenConnStartWatching(t *testing.T, cl client.Client) { +func VenConnStartWatching(ctx context.Context, t *testing.T, cl client.Client) { t.Helper() require.IsType(t, &client.VenConnClient{}, cl) @@ -116,7 +116,7 @@ func VenConnStartWatching(t *testing.T, cl client.Client) { // the message "timeout waiting for process kube-apiserver to stop". See: // https://github.com/jetstack/venafi-connection-lib/pull/158#issuecomment-1949002322 // https://github.com/kubernetes-sigs/controller-runtime/issues/1571#issuecomment-945535598 - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(ctx) go func() { err := cl.(*client.VenConnClient).Start(ctx) require.NoError(t, err)