korg: add userinfo command for org and OWNERS lookup#6398
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: palnabarun The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/assign @kubernetes/owners |
d785d6c to
427a4cc
Compare
Priyankasaggu11929
left a comment
There was a problem hiding this comment.
Thank you, @palnabarun!
left a few inline comments.
cblecker
left a comment
There was a problem hiding this comment.
Nice addition — this fills a genuine gap and the overall structure is solid. The errgroup concurrency pattern is correct, Hound failures degrade gracefully, and it's good to see tests land alongside the new code. A few things worth addressing before this merges, mostly around the JSON output dropping failed users and a double-print in main(). The go.mod changes are covered separately.
427a4cc to
573e357
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: palnabarun The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
573e357 to
b4e3c9e
Compare
|
@Priyankasaggu11929 @cblecker PTAL again. Thank you. 🙏🏽 |
b4e3c9e to
c575655
Compare
Adds `korg userinfo <user>...` to answer the recurring question this
repo exists for: which Kubernetes orgs is a user in, 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 file references
Behavior:
- Honors GITHUB_TOKEN / GH_TOKEN to avoid the 60/hr unauth limit
- 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
and the process exits non-zero
- Hound failures degrade to a warning instead of dropping org info
- OWNERS results render as an aligned REPO / PATH / URL table; URL
uses /blob/HEAD/ so the link resolves to the default branch
- `--output json` for scripting
Dependencies:
- google/go-github v17 (untagged) -> v88
- spf13/cobra v0.0.5 -> v1.10.2 (for ExecuteContext)
- adds golang.org/x/sync for errgroup
- go directive bumped to 1.22+
Review fixes:
- OWNERS/OWNERS_ALIASES search now matches "- <user>" as a literal
YAML list item and skips commented-out lines, cutting false
positives from prose mentions or substring matches
- Each hit is further confirmed against the file's real content via
`gh api` to exclude emeritus-only entries; toggle with
--verify-owners
- Fixed a double error-print in main() and dropped the unused ctx
param on newGitHubClient
- JSON output no longer silently drops per-user failures (entries
now carry username + error instead of vanishing)
- Copyright headers normalized to match repo convention
Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
c575655 to
65a1640
Compare
There was a problem hiding this comment.
The batch path is the most complex control flow here but only gets tested with single-user inputs. A mixed-batch test (e.g. ["alice", "ghost", "bob"] where ghost 404s) would exercise both branches of the JSON assembly loop in a single call and catch ordering / nil-dereference regressions.
There was a problem hiding this comment.
Text mode is the default output but has no test coverage -- all runUserinfo tests pass outputJSON=true. A TestRunUserinfoText that checks for the === username header, Company: line, Orgs: section, and tabwriter table would guard against formatting regressions in renderText.
Adds
korg userinfo <user>...to answer the recurring question thisrepo exists for: which Kubernetes orgs is a user in, what role, and
where do they appear in OWNERS files.
Sources
Behavior
--output jsonfor scriptingReview fixes
"- <user>"as a literal YAML list item and skips commented-out lines, cutting false positives from prose mentions or substring matchesgh apito exclude emeritus-only entries; toggle with--verify-ownersmain()and dropped the unusedctxparam onnewGitHubClientusername+errorinstead of vanishing)