From 1248be8bba2a8da55421a17323aa33efd49aec37 Mon Sep 17 00:00:00 2001 From: Tim Ramlot <42113979+inteon@users.noreply.github.com> Date: Tue, 7 May 2024 12:37:04 +0200 Subject: [PATCH] add contextcheck linter exceptions Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com> --- cmd/acmesolver/app/app.go | 1 + cmd/cainjector/app/cainjector.go | 1 + cmd/controller/app/start.go | 1 + cmd/startupapicheck/pkg/check/api/api.go | 1 + cmd/webhook/app/webhook.go | 1 + pkg/acme/webhook/cmd/server/start.go | 1 + test/e2e/suite/conformance/certificates/tests.go | 4 ++-- .../suite/conformance/certificatesigningrequests/tests.go | 6 ++++-- 8 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/acmesolver/app/app.go b/cmd/acmesolver/app/app.go index cd638b102..d2cc96cb6 100644 --- a/cmd/acmesolver/app/app.go +++ b/cmd/acmesolver/app/app.go @@ -46,6 +46,7 @@ func NewACMESolverCommand(_ context.Context) *cobra.Command { return nil }, + // nolint:contextcheck // False positive RunE: func(cmd *cobra.Command, args []string) error { runCtx := cmd.Context() log := logf.FromContext(runCtx) diff --git a/cmd/cainjector/app/cainjector.go b/cmd/cainjector/app/cainjector.go index ced1eb088..41dc22529 100644 --- a/cmd/cainjector/app/cainjector.go +++ b/cmd/cainjector/app/cainjector.go @@ -100,6 +100,7 @@ servers and webhook servers.`, return nil }, + // nolint:contextcheck // False positive RunE: func(cmd *cobra.Command, args []string) error { return run(cmd.Context(), cainjectorConfig) }, diff --git a/cmd/controller/app/start.go b/cmd/controller/app/start.go index ed5fc18e0..e3b4a9343 100644 --- a/cmd/controller/app/start.go +++ b/cmd/controller/app/start.go @@ -110,6 +110,7 @@ to renew certificates at an appropriate time before expiry.`, return nil }, + // nolint:contextcheck // False positive RunE: func(cmd *cobra.Command, args []string) error { return run(cmd.Context(), controllerConfig) }, diff --git a/cmd/startupapicheck/pkg/check/api/api.go b/cmd/startupapicheck/pkg/check/api/api.go index 4c7350a58..4ca6cef53 100644 --- a/cmd/startupapicheck/pkg/check/api/api.go +++ b/cmd/startupapicheck/pkg/check/api/api.go @@ -79,6 +79,7 @@ required webhooks are reachable by the K8S API server.`, PreRunE: func(cmd *cobra.Command, args []string) error { return o.Complete() }, + // nolint:contextcheck // False positive RunE: func(cmd *cobra.Command, args []string) error { return o.Run(cmd.Context(), cmd.OutOrStdout()) }, diff --git a/cmd/webhook/app/webhook.go b/cmd/webhook/app/webhook.go index 5d5565256..0009c59e7 100644 --- a/cmd/webhook/app/webhook.go +++ b/cmd/webhook/app/webhook.go @@ -107,6 +107,7 @@ functionality for cert-manager.`, return nil }, + // nolint:contextcheck // False positive RunE: func(cmd *cobra.Command, args []string) error { return run(cmd.Context(), webhookConfig) }, diff --git a/pkg/acme/webhook/cmd/server/start.go b/pkg/acme/webhook/cmd/server/start.go index fd953308f..fce320a1a 100644 --- a/pkg/acme/webhook/cmd/server/start.go +++ b/pkg/acme/webhook/cmd/server/start.go @@ -66,6 +66,7 @@ func NewCommandStartWebhookServer(_ context.Context, groupName string, solvers . cmd := &cobra.Command{ Short: "Launch an ACME solver API server", Long: "Launch an ACME solver API server", + // nolint:contextcheck // False positive RunE: func(c *cobra.Command, args []string) error { runCtx := c.Context() diff --git a/test/e2e/suite/conformance/certificates/tests.go b/test/e2e/suite/conformance/certificates/tests.go index a0697592d..fa60af321 100644 --- a/test/e2e/suite/conformance/certificates/tests.go +++ b/test/e2e/suite/conformance/certificates/tests.go @@ -1065,13 +1065,13 @@ cKK5t8N1YDX5CV+01X3vvxpM3ciYuCY9y+lSegrIEI+izRyD7P9KaZlwMaYmsBZq By("Updating the Certificate after having added an additional dnsName") newDNSName := e2eutil.RandomSubdomain(s.DomainSuffix) retry.RetryOnConflict(retry.DefaultRetry, func() error { - err = f.CRClient.Get(context.Background(), types.NamespacedName{Name: testCertificate.Name, Namespace: testCertificate.Namespace}, testCertificate) + err = f.CRClient.Get(ctx, types.NamespacedName{Name: testCertificate.Name, Namespace: testCertificate.Namespace}, testCertificate) if err != nil { return err } testCertificate.Spec.DNSNames = append(testCertificate.Spec.DNSNames, newDNSName) - err = f.CRClient.Update(context.Background(), testCertificate) + err = f.CRClient.Update(ctx, testCertificate) if err != nil { return err } diff --git a/test/e2e/suite/conformance/certificatesigningrequests/tests.go b/test/e2e/suite/conformance/certificatesigningrequests/tests.go index d7093f25c..f837d0ef6 100644 --- a/test/e2e/suite/conformance/certificatesigningrequests/tests.go +++ b/test/e2e/suite/conformance/certificatesigningrequests/tests.go @@ -393,9 +393,11 @@ func (s *Suite) Define() { // Create the request, and delete at the end of the test By("Creating a CertificateSigningRequest") Expect(f.CRClient.Create(ctx, kubeCSR)).NotTo(HaveOccurred()) + // nolint: contextcheck // This is a cleanup context defer func() { - // nolint: contextcheck // This is a cleanup context - f.CRClient.Delete(context.TODO(), kubeCSR) + cleanupCtx := context.Background() + + f.CRClient.Delete(cleanupCtx, kubeCSR) }() // Approve the request for testing, so that cert-manager may sign the