Commit 9e35aad
Read API key from K8s secret on every RPC call (#301)
## Summary
Follow-up to #300. Solves #295 more gracefully.
- Replaces the static `secret.Data` capture in the
`NewAPIKeyDynamicCredentials` closure with a live K8s secret read via a
new `fetchAPIKeyFromSecret` helper
- A rotated API key now takes effect on the next outgoing Temporal RPC —
no permission-denied cycle needed to evict and re-dial the cached client
- The k8s client is controller-runtime's cache-backed client, so reads
hit the local informer cache (cheap in-memory lookup, not a raw API
server call)
- `fetchAPIKeyFromSecret` is extracted as a testable method; new test
verifies the live-read and rotation behavior directly
## Test plan
- [ ] `go test ./internal/controller/clientpool/...` — new
`TestFetchAPIKey_CredentialClosureReadsLiveSecret` passes (verifies
initial read and post-rotation read return correct values)
- [ ] `go test ./internal/controller/...` — existing tests still pass
- [ ] `go build ./...` — compiles clean
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent cd5b2d2 commit 9e35aad
2 files changed
Lines changed: 56 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
203 | 206 | | |
204 | | - | |
| 207 | + | |
205 | 208 | | |
206 | 209 | | |
207 | 210 | | |
| |||
271 | 274 | | |
272 | 275 | | |
273 | 276 | | |
274 | | - | |
| 277 | + | |
275 | 278 | | |
276 | 279 | | |
277 | 280 | | |
| |||
327 | 330 | | |
328 | 331 | | |
329 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
330 | 341 | | |
331 | 342 | | |
332 | 343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
238 | 253 | | |
239 | 254 | | |
240 | 255 | | |
241 | 256 | | |
242 | 257 | | |
243 | | - | |
244 | 258 | | |
245 | 259 | | |
246 | 260 | | |
247 | 261 | | |
248 | 262 | | |
| 263 | + | |
249 | 264 | | |
250 | 265 | | |
251 | 266 | | |
| |||
259 | 274 | | |
260 | 275 | | |
261 | 276 | | |
262 | | - | |
| 277 | + | |
263 | 278 | | |
264 | 279 | | |
265 | 280 | | |
| |||
269 | 284 | | |
270 | 285 | | |
271 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
272 | 312 | | |
273 | 313 | | |
274 | 314 | | |
| |||
0 commit comments