From 55bb5b1dd5be1bbb7fabb11766adae50cf6a8816 Mon Sep 17 00:00:00 2001 From: Ross Golder Date: Mon, 10 Aug 2026 22:01:21 +0700 Subject: [PATCH] chore: resolve noctx linter issues (#1265) - Use exec.CommandContext instead of exec.Command in e2e tests - Use db.PrepareContext instead of db.Prepare in MySQL datastore --- e2e/utils_test.go | 13 ++++++++----- internal/datastore/mysql.go | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/e2e/utils_test.go b/e2e/utils_test.go index 671841c..7be5539 100644 --- a/e2e/utils_test.go +++ b/e2e/utils_test.go @@ -43,8 +43,8 @@ func PrintTenantControlPlaneInfo() { tcp := tcpList.Items[0] - kubectlExec := func(args ...string) { - cmd := exec.Command("kubectl") + kubectlExec := func(ctx context.Context, args ...string) { + cmd := exec.CommandContext(ctx, "kubectl") var out bytes.Buffer cmd.Stdout = &out @@ -65,20 +65,23 @@ func PrintTenantControlPlaneInfo() { if CurrentSpecReport().Failed() { _, _ = fmt.Fprintln(GinkgoWriter, "DEBUG: Tenant Control Plane definition") kubectlExec( - fmt.Sprintf("--namespace=%s", tcp.GetNamespace()), + context.Background(), + "--namespace="+tcp.GetNamespace(), "get", "tcp", tcp.GetName(), ) _, _ = fmt.Fprintln(GinkgoWriter, "DEBUG: Tenant Control Plane resources") kubectlExec( - fmt.Sprintf("--namespace=%s", tcp.GetNamespace()), + context.Background(), + "--namespace="+tcp.GetNamespace(), "get", "svc,deployment,pods,ep,configmap,secrets", ) _, _ = fmt.Fprintln(GinkgoWriter, "DEBUG: Tenant Control Plane pods") kubectlExec( - fmt.Sprintf("--namespace=%s", tcp.GetNamespace()), + context.Background(), + "--namespace="+tcp.GetNamespace(), "describe", "pods", ) diff --git a/internal/datastore/mysql.go b/internal/datastore/mysql.go index 0a95034..0a80d69 100644 --- a/internal/datastore/mysql.go +++ b/internal/datastore/mysql.go @@ -316,7 +316,7 @@ func (c *MySQLConnection) RevokePrivileges(ctx context.Context, user, dbName str } func (c *MySQLConnection) check(ctx context.Context, nonFilledStatement string, checker func(*sql.Row) (bool, error), args ...any) (bool, error) { - statement, err := c.db.Prepare(nonFilledStatement) + statement, err := c.db.PrepareContext(ctx, nonFilledStatement) if err != nil { return false, err }