diff options
| author | Jonathan Amsterdam <jba@google.com> | 2020-08-21 19:31:08 -0400 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2020-08-25 18:52:53 +0000 |
| commit | d25b304adb7670d05913a46af0cddcfca4e5cc02 (patch) | |
| tree | 5492903ac5630ead161bdee035f134ad5a8a1f9e /internal/testing/sample | |
| parent | 41dc6b274dec8f67939c151c82b50044b08a9fb5 (diff) | |
| download | go-x-pkgsite-d25b304adb7670d05913a46af0cddcfca4e5cc02.tar.xz | |
internal,internal/postgres: remove non-redist data on read
The postgres package removes non-redistributable data during
insertion. Also remove it when reading, unless bypassLicenseCheck is
true.
Handling this in the DataSource layer simplifies frontend code, which
can avoid redistributability checks and knowing about the bypass flag
except when it constructs its DataSource.
As part of this work, move the removal of non-redistributable data to
the internal package, so it can eventually be used by the proxy data
source.
For golang/go#39602
Change-Id: Ia1362ead917b42f844b4c4d25ade74cdcb03d4dc
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/250017
Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/testing/sample')
| -rw-r--r-- | internal/testing/sample/sample.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/testing/sample/sample.go b/internal/testing/sample/sample.go index ccffa670..cfd24504 100644 --- a/internal/testing/sample/sample.go +++ b/internal/testing/sample/sample.go @@ -44,6 +44,13 @@ var ( Licenses = []*licenses.License{ {Metadata: LicenseMetadata[0], Contents: []byte(`Lorem Ipsum`)}, } + NonRedistributableLicense = &licenses.License{ + Metadata: &licenses.Metadata{ + FilePath: "NONREDIST_LICENSE", + Types: []string{"UNKNOWN"}, + }, + Contents: []byte(`unknown`), + } DocumentationHTML = template.MustParseAndExecuteToHTML("This is the documentation HTML") PackageName = "foo" Suffix = "foo" @@ -237,6 +244,19 @@ func AddDirectory(m *internal.Module, d *internal.Directory) { m.Directories = append(m.Directories, d) } +func AddLicense(m *internal.Module, lic *licenses.License) { + m.Licenses = append(m.Licenses, lic) + dir := path.Dir(lic.FilePath) + if dir == "." { + dir = "" + } + for _, d := range m.Directories { + if strings.TrimPrefix(d.Path, m.ModulePath+"/") == dir { + d.Licenses = append(d.Licenses, lic.Metadata) + } + } +} + func DirectoryEmpty(path string) *internal.Directory { return &internal.Directory{ DirectoryMeta: internal.DirectoryMeta{ |
