Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GitHubClientFactory #3203

Merged
merged 1 commit into from
Apr 30, 2024
Merged

Implement GitHubClientFactory #3203

merged 1 commit into from
Apr 30, 2024

Conversation

dmjb
Copy link
Contributor

@dmjb dmjb commented Apr 29, 2024

Relates to #2845

For a future PR, I want to be able to easily instantiate the GitHub client without going through the provider creation process. Specifically - when creating providers, we end up partially creating a provider, storing it in the database, and then use instantiate it to verify that the user IDs are correct. I want to change this so that we instantiate the client without the provider to make the call we need.

This splits the code for creating the github client out into its own factory. As a bonus - this removes some code which is duplicated between the oauth and app provider instantiation flows.

Validated locally against both app and oauth flows.

Summary

Provide a brief overview of the changes and the issue being addressed.
Explain the rationale and any background necessary for understanding the changes.
List dependencies required by this change, if any.

Fixes #(related issue)

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@coveralls
Copy link

coveralls commented Apr 29, 2024

Coverage Status

coverage: 50.52% (-0.07%) from 50.594%
when pulling 5b037c9 on github-client-factory
into 3b90c28 on main.

Relates to #2845

For a future PR, I want to be able to easily instantiate the GitHub
client without going through the provider creation process. This splits
the code for creating the github client out into its own factory. As a
bonus - this removes some code which is duplicated between the oauth
and app provider instantiation flows.
@dmjb dmjb marked this pull request as ready for review April 30, 2024 09:34
@dmjb dmjb requested a review from a team as a code owner April 30, 2024 09:34
@dmjb dmjb marked this pull request as draft April 30, 2024 11:18
@dmjb dmjb marked this pull request as ready for review April 30, 2024 11:18
@puerco puerco self-requested a review April 30, 2024 13:07

// If $MINDER_LOG_GITHUB_REQUESTS is set, wrap the transport in a logger
// to record all calls and responses to from GitHub:
if os.Getenv("MINDER_LOG_GITHUB_REQUESTS") != "" {
Copy link
Member

Choose a reason for hiding this comment

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

We should move this to some actual configuration at some point, or remove this hook.

(Doesn't need to be part of this PR)


// If $MINDER_LOG_GITHUB_REQUESTS is set, wrap the transport in a logger
// to record all calls and responses to from GitHub:
if os.Getenv("MINDER_LOG_GITHUB_REQUESTS") != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, but it would be nice to keep a histogram of the values of x-ratelimit-remaining across our GitHub clients.

@dmjb dmjb merged commit f894476 into main Apr 30, 2024
23 checks passed
@dmjb dmjb deleted the github-client-factory branch April 30, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants