xlang-go: add the internal raw API as the highest priority source of zip archives
Created by: chrismwendt
sg/raw
so that the diff only shows my changes, but I do not intend to merge it into sg/raw
. I will retarget master
once sg/raw
is merged into master
.
Note to reviewers This PR is based on the new raw API https://github.com/sourcegraph/sourcegraph/pull/800, so jump to the end of the list of commits to find my changes.
Previously there were 3 sources from which xlang-go could get a zip archive (tried in this order):
- From gitserver over HTTP (can serve private repos, whatever exists on the Sourcegraph instance)
- From codeload.github.com over HTTP
- Full git clone, followed by
git archive --format=zip
This PR adds the internal raw API .internal/<repo>@<rev>/-/raw
to the top of that list of sources where xlang-go could get a zip archive for a particular repo@rev.
I have left gitserver in the list because I suspect that the xlang-go could be deployed and run against older Sourcegraph instances that do not support the raw API, which would result in no code intelligence on private repos (codeload.github.com and the full git clone are both unauthenticated). @keegancsmith Does this sound correct?
Conveniently, this change doesn't actually depend on the raw API, since the absence of the raw API will simply cause a 404 and xlang-go will happily try the next source in the list.
Looking ahead to when code gets moved to go-langserver and gitserver is omitted, I anticipate we'd like to add some command line flag to supply a comma-separated list of format specifiers for arbitrary zip archive URLS, for example:
$ xlang-go -ziptemplates=https://codeload.%s/zip/%s
$ xlang-go -ziptemplates=https://codeload.%s/zip/%s,http://frontend/.api/%s@%s/-/raw
This could easily provide support for Athens https://docs.gomods.io/intro/protocol/
This PR does not need to update the CHANGELOG because this doesn't make any user-visible changes.