owenthereal / upterm

Instant Terminal Sharing
https://upterm.dev
Apache License 2.0
816 stars 53 forks source link

GitHub list team members #192

Closed bavarianbidi closed 9 months ago

bavarianbidi commented 9 months ago

This PR is based on the branch used in https://github.com/owenthereal/upterm/pull/191 (so let's get #191 done first). Use commit c6e8a63 to see the new feature.

Instead of adding multiple github users it would be also nice to only define at least one team in github and add all users to the list of users to lookup for a public key.

TODO:

owenthereal commented 9 months ago

This use case is interesting. I would say perhaps the best way is to combo upterm with the gh CLI for such a use case:

upterm host $(gh api /orgs/ORG_NAME/teams/TEAM_NAME/members | jq -r 'map("--github-user \"\(.login)\"") | join(" ")')

The above gets all team members for a team and supply their logins as --github-user LOGIN into the upterm host command with jq. We have to strike a balance of how deep integration upterm should go with external APIs.

bavarianbidi commented 9 months ago

@owenthereal thanks for your recent changes towards our needs.

Unfortanetly for the github-team-member-lookup the token need more permissions. In my case i can't do a login with the limited token i've used in this branch. It seems that gh is doing some additional requests instead of the api-requests from google/go-github.

runner@road-runner-os023-l-h28fgkqwkhfb:~/actions-runner/_work/pipeline-test/pipeline-test$ echo $GITHUB_TOKEN | gh auth login -h $GH_HOST --with-token
error validating token: missing required scope 'repo'

will try to work around that to make it work - maybe by duing a curl request for that. Will let you know about the result.

UPDATE

yes indeed,

doing a plain curl (documented in the official gh documentation) works fine where the gh api subcommand requires a successful gh auth login first to work ... and gh auth login requires a token with repo scope :disappointed: ).

will continue with curl for now