Skip to content

frontend: use #40827 to provide the src-cli version and download endpoints

Administrator requested to merge aharvey/version-cache-usage into main

Created by: LawnGnome

This PR uses the sourcegraph.com API added in #40827 to implement the /.api/src-cli/version and /.api/src-cli/{download} endpoints, rather than calling out to GitHub directly.

There's also some new caching added that should mean that Sourcegraph instances don't hammer sourcegraph.com with these requests either.

If the API is unavailable or unreachable, the previous behaviour of falling back to the MinimumVersion constant is preserved. This is mostly going to come into play with any early rollouts of Sourcegraph 4.0 that occur before sourcegraph.com is upgraded to 4.0, but I don't think the behavioural change is significant enough to be a problem.

Fixes #39468 (closed).

Test plan

There's good test coverage, and I've done a bunch of testing locally of the various scenarios, monitoring the requests with ngrok to ensure that the cache behaves as expected and the sourcegraph.com API isn't hit more often than expected.

Merge request reports

Loading