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

Split some more of github apart, structs for clients, attach methods to structs, stop passing around copies of things by value, etc... #56

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DarthHater
Copy link
Member

I mostly focused on our github package, and did a few things, adding some interfaces, helper methods for obtaining things, and trying to stuff things in the right areas so we are constantly passing around loggers, etc...

I THINK this looks cleaner, and it feels cleaner.

Beyond that, I implemented one new API (I think) around checking the GH API (via JWT auth, which is new too) about our apps install, so I can get the botname, etc....

…nfo on our App asking GH via the install API what it is called, etc...
return c.String(http.StatusBadRequest, err.Error())
}

// See if we can move this to a longer lived thing, maybe? It's going to recreate the transport and http Client each time we get a payload
Copy link
Member Author

Choose a reason for hiding this comment

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

I have ideas on how we can do this. INSTALL ID may change intermittently, but most other things should stay the same. We can allow someone to update the installID on ghClient, and inside we can say "hey, before you make a request, refresh your token real quick". That's my quick thought on it, so that ghClient can be longer lived?

@@ -142,7 +146,47 @@ func handleProcessWebhook(c echo.Context) (err error) {
case webhook.PullRequestPayload:
switch payload.Action {
case "opened", "reopened", "synchronize":
res, err := ourGithub.HandlePullRequest(c.Logger(), postgresDB, payload, appId, getCurrentCLAVersion())
// Getting a JWT Apps Transport to ask GitHub about stuff that needs a JWT for asking, such as installInfo
atr, err := ghinstallation.NewAppsTransportKeyFromFile(http.DefaultTransport, int64(appId), filenameTheClaPem)
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved the transport setup up a level from github, because technically we can make these transports longer lived as well.

bhamail added a commit that referenced this pull request Feb 2, 2022
#60)

* found a way to get the App ExternalURL - Thanks @DarthHater!
Fixes #59
@sonarcloud
Copy link

sonarcloud bot commented Aug 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

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.

None yet

2 participants