Commit 8b238be
committed
korg: add userinfo command for org and OWNERS lookup
Adds `korg userinfo <user>...` to answer the recurring question this repo
exists for: which Kubernetes orgs is a user in, with what role, and where
do they appear in OWNERS files.
Sources:
- GitHub user API for company / profile
- config/<org>/org.yaml (Members / Admins) for k8s org membership
- cs.k8s.io (hound) for OWNERS / OWNERS_ALIASES references
Behavior:
- Honors GITHUB_TOKEN / GH_TOKEN to avoid the 60/hr unauth limit. GitHub
and hound use separate http.Client instances, so the token is never
sent to cs.k8s.io
- Per-request context with a 30s timeout; SIGINT cancels in flight
- Multi-user batches run concurrently (errgroup, bounded to 4) with
output preserved in input order
- One bad username does not kill the batch; per-user errors render in
both text and JSON output, and the process exits non-zero
- Hound failures degrade to a warning instead of dropping org info
- `--output json` for scripting
OWNERS matching:
- Anchors the hound query on "- <user>" and keeps a hit only when the
YAML list item equals the username exactly, so prose mentions,
commented-out entries and substring near-misses ("- alice-bot" for
"alice") are all dropped. Surrounding quotes and trailing inline
comments are stripped first, so `- "alice"` and "- alice # area expert"
still match
- Each surviving hit is confirmed against the file's real content via
`gh api` to exclude emeritus-only entries, toggled by --verify-owners.
A hit that cannot be fetched is kept with a warning rather than dropped
- Results render as an aligned REPO / PATH / URL table; the URL uses
/blob/HEAD/ so the link resolves to the default branch
Tests:
- Table-driven coverage of the OWNERS match filter (quoted values, inline
comments, commented-out entries, substring near-misses), emeritus
exclusion, and the fail-open path when a hit cannot be verified
- Batch coverage for both output modes: input ordering, mixed
success/failure runs, and the text renderer's company / orgs fallbacks
- Asserts hound requests carry no Authorization header while GitHub
requests stay authenticated
Dependencies:
- adds github.com/google/go-github/v88 for the user API
- promotes golang.org/x/sync from indirect v0.2.0 to direct v0.8.0 for
errgroup
- go directive 1.22.4 -> 1.25.0
Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>1 parent 3a5430e commit 8b238be
5 files changed
Lines changed: 1352 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
61 | 85 | | |
62 | 86 | | |
63 | 87 | | |
| |||
222 | 246 | | |
223 | 247 | | |
224 | 248 | | |
225 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
226 | 275 | | |
227 | 276 | | |
228 | 277 | | |
0 commit comments