plugin: support GitHub Enterprise Server as plugin source #1751
+118
−24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
GitHub Enterprise Server is a private installation of GitHub. It provides a compatible API, but on a hostname other than
github.com
. This PR removes the requirement that plugin sources begin withgithub.com
and assumes any other hostname is a GHES server hostname. If it's not, the client would likely receive a 404, which hopefully is enough "validation." But if needed, we could make a request an look for a header to explicitly fail with "this server is not GitHub."I factored out the request logs into a logging transport to avoid the need to to reverse engineer URLs. Otherwise,
client.BaseURL.JoinPath
is the next best way to generate a URL relative to the client.Still thinking about how to test this. The only reasonable way would seem to be to run a mock server using
httptest
and then pass its URL, or at least the hostname part, as the SourceHost. I believe this is alwayslocalhost
on a random port, which technically isn't expected in SourceHost, but should work in practice right now. However, given the amount of boilerplate involved in mocking out the responses from GitHub, we could potentially just merge this and let users try it, knowing that we at least have regression testing forgithub.com
.Closes #1643