openshift / backplane-tools

Manages the tools needed to interact with clusters
Apache License 2.0
4 stars 28 forks source link

Add string "github.com" to token lookup #70

Closed clcollins closed 4 months ago

clcollins commented 4 months ago

The function auth.TokenForHost() assumes a string argument to properly identify the token lookup method for the host. Due to a bug(?) in the auth package, if an empty string is provided, it ends up looking for GitHub Enterprise credentials, and returns an empty token if it doesn't find them. Since we're assuming the token is provided either in the gh config or the GH_TOKEN env, when it is using the latter, calls to GitHub are not authenticated.

This PR uses "github.com" as the string for auth.TokenForHost(), to ensure credentials (including GH_TOKEN) are properly retrieved from the environment.

I have confirmed this to work with a container image build testing backplane-tools install all, and checking the rate limit, x-ratelimit-used has only incremented by one (which is the call to check the limit itself) after a full backplane-tools install run.

Signed-off-by: Chris Collins collins.christopher@gmail.com

openshift-ci[bot] commented 4 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clcollins

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/openshift/backplane-tools/blob/main/OWNERS)~~ [clcollins] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
tnierman commented 4 months ago

/lgtm

openshift-ci[bot] commented 4 months ago

@clcollins: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).