Граф коммитов

114 Коммитов

Автор SHA1 Сообщение Дата
Julie Qiu 43b1879f55 internal/version: drop Version suffix from constants
To avoid repetition, the "Version" suffix in version.LatestVersion,
version.MainVersion, and version.MasterVersion are dropped.

The current version.Latest function is renamed to version.LatestVersion.

Change-Id: I649229939223b686dd95a137df4871a899f48aab
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/325390
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-06-07 16:08:09 +00:00
Julie Qiu ae6779bbf2 internal: move version constants to internal/version
Because the constants for "latest", "master" and "main" were in package
internal, we couldn't use them in internal/stdlib due to an import
cycle.

They are now moved to  internal/version to avoid this cycle.

Change-Id: I6ebe7c0f50037be2b047c4a25054a0531dcfd3f8
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/325389
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-06-07 16:08:05 +00:00
Jonathan Amsterdam 3adcef48f6 internal/proxy: fix error reporting
We weren't reporting on NotFound, but the right code is NotFetched,
since that is what is returned when proxy fetch is disabled.

Change-Id: I554d5186fb4db0346fb9456fe9fc55091066abda
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/320751
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-05-18 16:14:20 +00:00
Julie Qiu 5eed0f6bc9 internal/frontend: support displaying multiple of same type
Previously on the versions page, we were not handling the case when
different identifiers are added for the same type for different build
contexts, and which build context was surfaced was based on chance.

To support this case, it is now possible to show multiple of the same
type at the same version. For example,
https://pkg.go.dev/internal/poll?tab=versions at go1.10 will show:

```
type FD — windows/amd64
+ func (fd *FD) ReadMsg(p []byte, oob []byte) (int, int, int, syscall.Sockaddr, error)
+ func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, error)

type FD — darwin/amd64, linux/amd64
+ func (fd *FD) SetBlocking() error
+ func (fd *FD) WriteOnce(p []byte) (int, error)
```

For golang/go#37102

Change-Id: I19e6ef12f1f8f9c412aab7cea2782409eecf29f9
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/317489
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-05-06 17:43:23 +00:00
Julie Qiu f6463665d1 internal/testing/integration: add test for duplicate symbols
An integration test is added for these cases:

- A symbol changes across different build contexts
- A symbol is introduced at different versions for different build contexts
- The package symbol for a symbol changes because its parent changes,
  but the name and synopsis are the same

For golang/go#37102

Change-Id: Ieca17042e11b2fd583e2133a3064ab6043a29858
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/316969
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-05-05 16:36:49 +00:00
Julie Qiu f051c461d6 internal/frontend: change symbol history logic
The frontend now displays different synopsis for the same symbol, if
they change based on build context.

For golang/go#37102

Change-Id: Id0887efbcc263434e5d25b9149e480c005d09f2d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/316549
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-05-04 18:43:00 +00:00
Julie Qiu 1006123e19 internal: add integration test for v3 module for symbols
For golang/go#37102

Change-Id: Idf5b5ace37e2373874069e65b2e0dfd859b5eda9
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/314539
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-04-29 16:48:38 +00:00
Julie Qiu cbfb973078 internal/proxy/testdata: add rsc.io/quote
Change-Id: I7fce0b0af32b6a714e7fd2254c995a8a0169cf01
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/314530
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-04-28 19:42:11 +00:00
Julie Qiu 0ebe34c7d8 internal/proxy: use module path from go.mod in txtar file
Rather than generating a module path that always begins with
"example.com", readTxtarModule now reads the module path from the go.mod
section of the txtar file when one is present.

Change-Id: I77ad7cded2a25da0eeb996f0a465be28120a887e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/314531
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2021-04-28 19:40:43 +00:00
Jamal Carvalho e88261ff22 internal/worker: downgrade proxy errors to warning level
To reduce noise from proxy errors, downgrading
them to a warning and excluding them from error
reporting.

Change-Id: I1e1245ea534a6dd172587f9c13689b79fcf27001
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/306129
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-04-26 15:41:02 +00:00
Jonathan Amsterdam c269e808f7 internal/proxy: support caching the last zip
To avoid downloading a zip twice when processing a module,
implement a one-element zip cache in the proxy client.

The test in internal/worker/fetch_test.go explains in
more detail when this is useful.

For golang/go#44710

Change-Id: I89e67a5452833a7300fc2e10981e2b59594f10a9
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/302532
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-03-17 20:58:12 +00:00
Julie Qiu 6fbbcea017 content,internal/frontend: present since_version to main page
Information about when a symbol is added to the package is now presented
on the main unit page behind a feature flag.

For golang/go#37102

Change-Id: I21fc3aa7c6569b07d5b42409f6cb7db0e22dbf96
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/300673
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-03-15 17:34:19 +00:00
Julie Qiu a2f4692c7e internal/frontend: add version history
Symbol history is added to the versions page, for when a symbol is first
introduced to the package API.

For golang/go#37102

Change-Id: I22b7bc959a464dc38fe0bd39244c997fd51370f1
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/298309
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-03-09 21:48:37 +00:00
Jonathan Amsterdam 793c4cafdf internal/fetch: handle lack of version information
The proxy may have no version information even for a module that it
knows about.

For example:

```
> curl $GOPROXY/cloud.google.com/go/compute/metadata/@v/v0.0.0-20181107005212-dafb9c8d8707.info
{"Version":"v0.0.0-20181107005212-dafb9c8d8707","Time":"2018-11-07T00:52:12Z"}

> curl  $GOPROXY/cloud.google.com/go/compute/metadata/@v/list

> curl -i $GOPROXY/cloud.google.com/go/compute/metadata/@latest
HTTP/2 410
```

If that happens, fetch.LatestModuleVersions returns nil and nothing is
added to the DB.

For golang/go#44710

Change-Id: I6710bbb643192f71c73424255153bc339be07a87
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/298629
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-03-04 17:58:02 +00:00
Jonathan Amsterdam db6feab522 internal/proxy: remove logging
Change-Id: I06ed91e2345e45ef4a7976462caa762466cf182e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296813
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-26 20:46:46 +00:00
Jonathan Amsterdam 25114b8522 intern/proxydatasource: increase test timeout
Test is timing out in CI (can't repro locally).

Also add some logging.

Change-Id: I72ef35b94ff81c83fd2cd5ca5a7f69c9f31ce302
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/295893
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-24 23:08:16 +00:00
Jonathan Amsterdam bae9224b4a internal/worker: call WithFetchDisabled sooner
Convert the proxy client to one which doesn't fetch at the beginning
of the request, so we don't have to pass a boolean argument through
several layers.

For golang/go#44437

Change-Id: I0495b5673cc399a1cdc16349d53ba4a9a4ecc380
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/295889
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-24 16:09:16 +00:00
Jonathan Amsterdam 9af5659088 internal/proxydatasource: implement deprecation and retractions
When fetching a module at a version, the proxy datasource uses
fetch.RawLatestInfo to get the go.mod file at the raw latest version
of the module, then uses internal.RawLatestInfo.PopulateModule to
determine whether the module version is deprecated or retracted.

Also, add some proxy test modules to facilitate testing.

For golang/go#41321
For golang/go#43265
For golang/go#44437

Change-Id: I312346d72f656e598ad170135046ef85da8e9b11
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/295430
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-24 12:24:04 +00:00
Julie Qiu f15a2b1f07 internal/stdlib: fix Zip for master version
An error is fixed when creating the zipfile for std@master, which
prevented the module from being fetched. A test is also added.

For golang/go#44390

Change-Id: I279146aef10311822f47f16259a2223c879140c2
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/294831
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-02-22 22:19:41 +00:00
Jonathan Amsterdam ad24e8b060 internal/proxy: clarify that Info can return @latest
Change-Id: I4cd990a0f1189f5a7841de941a572a9a44c19632
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/294632
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-02-22 17:00:01 +00:00
Jonathan Amsterdam 287597ecc5 internal/proxy: more idiomatic method names
Remove the "Get" and "List" prefixes from proxy client method names.

The word "Get" is redundant for the proxy, since all you can do is get
stuff. It's also more idiomatic to avoid it when feasible.

Change-Id: I7d45fe06ab7a44083ff1ba75b284ec96fb785fe0
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/294631
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-21 12:37:16 +00:00
Jonathan Amsterdam 2e93faeff7 internal/proxy: simplify and generalize disable-fetch
Instead of a special one-off method that sets the Disable-Module-Fetch
header, make it a property of the client.

This makes it easy to send the header for every request.

Change-Id: I4b5920d6852127e500e5eeaf187b3782db629bfb
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/294630
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-21 04:28:43 +00:00
Jonathan Amsterdam 7015347762 internal/proxy: add stack traces to wrapped errors
For golang/go#44231

Change-Id: Ia285ee6f2493180727198cf9a1684f8d32fe2e64
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/291550
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-12 19:33:44 +00:00
Jonathan Amsterdam d656292fef internal/{proxy,middleware,derrors}: don't report proxy-timed-out errors
If the proxy times out, don't call the Error-Reporting API.

Change-Id: Ia5e3f776e386b54f35d71e5839d0a6600708ca8d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/291451
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-12 18:12:57 +00:00
Jonathan Amsterdam ff5a7a3f63 internal/proxy/testdata: add standard examples
Add some examples that will be used in tests,
and provide a way to load them into proxy.Modules.

For golang/go#44214

Change-Id: Ia05b8d8e27071d821532e8747e1ab3b6e05085a0
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290894
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2021-02-10 22:15:37 +00:00
Jonathan Amsterdam 89567d0152 internal/proxy: enhance Module
Add some methods to the Module struct to make it easy to modify a
Module to create a variant for testing.

Move all Module-related code to a separate file.

For golang/go#44214

Change-Id: I4fb6026a7550641a0eda9d768e152cd65ce80b99
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290893
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2021-02-10 22:15:19 +00:00
Julie Qiu b8fb1f1e02 internal/proxy: do not report not found errors
Change-Id: Idf00e06664a75d847089c768421fd177ceab0a4e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/286374
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2021-01-25 20:22:03 +00:00
Jonathan Amsterdam ae2dc097c1 internal/derrors,etc.: report errors lower in the stack
The data we get from the errorreporting API isn't too useful
because the call to Report happens high on the stack. Try
to call Report closer to where the error happens.

Change-Id: I101fb4de0892c5d9967f6eb46d7c9cbd72fb567e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/278952
Trust: Jonathan Amsterdam <jba@google.com>
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2020-12-17 22:59:01 +00:00
Jonathan Amsterdam 02a7088070 internal/proxy: support Disable-Module-Fetch header in fetch
Add Client.GetInfoNoFetch, which sets the Disable-Module-Fetch
header to avoid fetching a module from the proxy if it isn't in
the proxy's cache. This reduces load on the proxy.

We return the new error code NotFetched instead of NotFound in this
case, so we can distinguish modules where this happened in the DB.

Change-Id: I2134d09e09b115e2ed59ba1a479ef20c1ebe4a7e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/277812
Trust: Jonathan Amsterdam <jba@google.com>
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2020-12-16 10:33:44 +00:00
Julie Qiu 91e83ca203 internal: add support for path@main
Support requests for path@main in addition to path@master.

For golang/go#41312

Change-Id: Ie7665fbb3906e366c784a9cc592ffe37ef347671
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/274244
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-12-02 00:41:42 +00:00
Julie Qiu f1ac6e3ac6 internal/proxy: rename version to requestedVersion
Various uses of the variable version is renamed to requestedVersion for
clarity.

Change-Id: I542503a183f0b584689fe7fef6366e8555c3f84a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/256177
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-09-21 20:13:08 +00:00
Jonathan Amsterdam d5afe0e09b internal/proxy: implement GetZipSize
Provide an efficient way to get the size of a module zip file
without downloading it.

For golang/go#41452

Change-Id: I9a996efb83146109a31e73b302af1b49f197b43f
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/255737
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2020-09-17 21:22:30 +00:00
Jonathan Amsterdam 0f45b743e2 internal/proxy: GetZip no longer calls GetInfo
Avoid the call to GetInfo by requiring the version arg is already
resolved.

This was already true for the single non-test call to GetZip.

Change-Id: Id4992cffb9dd8b0b227cdcb9a5e71cc2345619e0
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/255577
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2020-09-17 21:22:20 +00:00
Julie Qiu 909213404b cmd,internal: clean up package documentation
Several packages were missing package documentation, which is now added.

Change-Id: I1a88ebebaee0fddeb5a7bb9e2573375ad887c311
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/253607
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-09-09 21:13:21 +00:00
Julie Qiu 4d4b7bf939 internal/worker: downgrade proxy timed out errors
If a fetch request failed due to a proxy timed out error, log this as an
INFO level log instead of an ERROR.

Change-Id: I2677a23e2dc9595f9040b78bec8d4be11b023068
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251917
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-09-01 14:33:32 +00:00
Jonathan Amsterdam 52e89c1eaa internal/proxy: return BadModule on bad zip
If zip.NewReader can't open the zip file, treat this as a bad module
(490) rather than a server error (500). That way we won't pointlessly
retry fetching the module.

Fixes b/166101385

Change-Id: I1c9999b09ff605b20cd420b43f016c7c0218c63a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/250237
Reviewed-by: Julie Qiu <julie@golang.org>
2020-08-24 16:10:24 +00:00
Julie Qiu 03d34d43ff internal/proxy: rename testhelper functions
TestProxyServer is renamed to NewClientForServer, so that the function
doesn't have a "Test" prefix when it is not a test.

SetupTestProxy is renamed to SetupTestClient, since it returns a
proxy.Client, and proxy.SetupTestClient reads better.

Change-Id: I6c3152638e29b41e61275174df5e08e7eef5b2c4
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/247297
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-07 14:32:58 +00:00
Julie Qiu 21e796723a internal/proxy: return proxy timed out errors
When the proxy times out on a request, it returns a status 404 with the
response text "not found: fetch timed out".

Rather than storing these as 404s in module_version_states, they are now
stored as 504, so that we will automatically retry fetching them.

Change-Id: I952bc9df8af2a108fffb04aef1c5fada98ccf0f7
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245903
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-07 13:09:01 +00:00
Julie Qiu bedaa11b04 internal/proxy: refactor TestGetZip
Change-Id: Ica6a4a187f4afa5a680b4aa148fcdd67f6933f7d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/247278
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-07 01:22:26 +00:00
Julie Qiu 0466666957 internal/proxy: use sample.ModulePath and sample.VersionString
Change-Id: I9b803fbf88ce2a893534e7856728abfc1e9d145b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/247277
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-07 01:22:12 +00:00
Julie Qiu 0366212962 internal/proxy: add Server
A Server is added to internal/proxy, which can be used to create a local
proxy server. In addition to the existing functionality of the test proxy,

Server supports the following:
- AddModule adds an additional module to the dataset of the proxy server
- The result of the latest and list endpoints are updated dynamically if
  AddModule is called
- AddRoute adds an additional route to the proxy server

TestProxyServer now accepts a *Server instead of a *http.ServeMux. This
will be used for tests for frontend fetch in later CLs.

Change-Id: Iccc46f4c47d4b90bc1fd9bb061f2798c5dbb5b9d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245119
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2020-08-06 19:27:19 +00:00
Julie Qiu 86c2ab588f internal/proxy: remove URL validation in New
Rather than validating the URL in proxy.New, assume that the URL that is
passed in is valid. This allows users to connect to a proxy running
locally in direct proxy mode.

For golang/go#40371

Change-Id: Id51cb27148987e58d214cef1c805b26b5138a6de
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245639
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-29 21:04:21 +00:00
Julie Qiu 19e31bfe34 internal/proxy: rename TestModule to Module
TestModule is renamed to Module, since it is shorter and proxy.Module is
equally descriptive as an exported variable.

Change-Id: Iebce664fa6e4580a4ab6b62fb73ad4bff611d067
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245118
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-28 14:16:45 +00:00
Julie Qiu bc86231ae8 internal/proxy: link TODO in test_helper.go to Go issue
Change-Id: Ia90874ef93a3c51a9fe50770824ad22498c01ce1
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240941
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-06 15:01:38 +00:00
Julie Qiu 940b33f7fc internal/proxy: add missing defer to New
Change-Id: I4b1f5d89febd3094dd9e8d4c2c5d3acd3f5ea3de
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/239358
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-22 21:38:54 +00:00
Julie Qiu 45475dd537 {cmd,internal}/frontend: add handler to download paths that do not exist
A fetch endpoint is added to the frontend, which will queue a module to
be enqueued by the worker, if it doesn't already exist in the database.

After enqueuing, the fetch handler will poll the version_map table at a
constant rate, until the path returns or the request times out.

If the request fails, a corresponding statusCode and responseText will
be returned to be displayed to the user.

Updates golang/go#36811
Updates golang/go#37002
Updates golang/go#37106

Change-Id: Ic2e20146dc626bf296db05bc2abbfb50d6fd7991
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/743103
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-04 15:55:57 +00:00
Julie Qiu 19794c8aeb all: rename module to golang.org/x/pkgsite
golang.org/x/discovery is renamed to golang.org/x/pkgsite.

When the repository is open sourced, it will be hosted at
go.googlesource.com/pkgsite.

Change-Id: Ifc3b45b771a385b99179e785447f2a87afcacf87
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/724273
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-23 16:18:43 +00:00
Julie Qiu fbbdc90992 internal/proxy: delete license testadata
proxy.TestModule now uses license testdata that already lives in
internal/testing/testdata.

Any TestModule that previously had a BSD3
license now has a BSD0 license, since the BSD0 license was already
present in internal/testing/testdata, and the type of
license for those tests did not matter, as long as it was redistributable.

Change-Id: Ic8837b2fe54e51e52086c859b1937de3269f8d2b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/710138
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06 17:09:52 -04:00
Julie Qiu a74eb69675 internal/proxy: deprecate defaultModules
Rather than having modules shared between packages, testdata now lives
in the package for which it is being used.

As a result, proxy.defaultModules is deprecated, and
proxy.SetupTestProxy requires any modules to be served to be passed as
args.

Change-Id: Ib307ab5a413cb254e8ceb97c8f36009f3b370c8d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/710008
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06 17:09:52 -04:00
Julie Qiu 92952752e8 internal/proxy: move testdata specific to fetch package
Testdata that is only used by the fetch package, but lives in
internal/proxy, is moved to internal/fetch.

Change-Id: I1cbc85e2efe060945c15a857b2230d193b4e5ac1
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/710004
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06 17:09:52 -04:00