mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 15:11:29 +00:00
b577f6f251
CI run #428 (job 74148571711) failed on commitc8eb3e0with: cmd/agent/main.go:690:44: Function `createTargetConnector` should pass the context parameter (contextcheck) Pre-existing on master since the Rank 5 commits (8a56a78Azure KV,edf6beeAWS ACM) added two `case` branches in createTargetConnector that called `awsacm.New(context.Background(), &cfg, a.logger)` and `azurekv.New(context.Background(), &cfg, a.logger)` instead of threading the caller's ctx. The contextcheck linter (in .golangci.yml) flagged the call site at line 690 because the caller — the deploy path inside processJob — has a `ctx` in scope (used a few lines later for `a.reportJobStatus(ctx, ...)`). Why CI fix #15 (c8eb3e0) didn't catch this: that commit was scoped narrowly to fix go.mod / go.sum drift after Azure SDK transitive deps shifted; it didn't run the full lint gate locally because the sandbox disk-pressure path falls back to gofmt + go vet + go test -short, and contextcheck is part of golangci-lint (not vet). It surfaced once CI ran the full lint pipeline. Fix: - createTargetConnector signature: prepend `ctx context.Context` as the first parameter (matches the convention used everywhere else in the agent — heartbeat, processJob, reportJobStatus, etc.). - Inside the function, replace both `context.Background()` calls (AWSACM + AzureKeyVault cases) with `ctx`. SDK credential resolution now honors caller cancellation / deadlines. - Update the production call site at cmd/agent/main.go:690 to pass `ctx` (already in scope). - Update the 6 test call sites in cmd/agent/agent_test.go to pass `context.Background()` (test functions don't have a ctx in scope — Background() is the conventional zero-value for unit tests). Verified locally: - gofmt: 0 lines diff - go vet ./cmd/agent/...: exit 0 - go build ./cmd/agent/...: exit 0 - go test -short ./cmd/agent/...: ok 11.912s The contextcheck linter itself wasn't re-run locally (golangci-lint install needs ~300MB and the sandbox modcache + build cache already filled disk). The fix matches the linter's diagnosis verbatim: "should pass the context parameter" — call site now passes the parameter; signature now accepts it.