Skip to content

korg: add userinfo command for org and OWNERS lookup#6398

Open
palnabarun wants to merge 1 commit into
kubernetes:mainfrom
palnabarun:korg/memberinfo
Open

korg: add userinfo command for org and OWNERS lookup#6398
palnabarun wants to merge 1 commit into
kubernetes:mainfrom
palnabarun:korg/memberinfo

Conversation

@palnabarun

@palnabarun palnabarun commented May 24, 2026

Copy link
Copy Markdown
Member

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.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

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

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added area/github-management Issues or PRs related to GitHub Management subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 24, 2026
@palnabarun

Copy link
Copy Markdown
Member Author

/assign @kubernetes/owners

@Priyankasaggu11929 Priyankasaggu11929 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @palnabarun!

left a few inline comments.

Comment thread cmd/korg/userinfo.go Outdated
Comment thread cmd/korg/userinfo.go Outdated
Comment thread cmd/korg/userinfo.go Outdated
Comment thread cmd/korg/userinfo.go
Comment thread cmd/korg/userinfo_test.go Outdated

@cblecker cblecker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread go.mod Outdated
Comment thread go.mod Outdated
Comment thread cmd/korg/korg.go Outdated
Comment thread cmd/korg/userinfo.go
Comment thread cmd/korg/userinfo.go
Comment thread cmd/korg/userinfo.go
Comment thread cmd/korg/userinfo.go Outdated
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 3, 2026
@palnabarun

Copy link
Copy Markdown
Member Author

@Priyankasaggu11929 @cblecker PTAL again. Thank you. 🙏🏽

  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>
Comment thread cmd/korg/userinfo_test.go

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cmd/korg/userinfo_test.go

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/github-management Issues or PRs related to GitHub Management subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants