internal: rename ModuleInfo to LegacyModuleInfo
ModuleInfo is renamed to LegacyModuleInfo, as a step towards
deprecating LegacyReadmeFilePath and LegacyReadmeContents.
In a follow up CL, we will add ModuleInfo as an embedded struct
to LegacyModuleInfo.
Change-Id: Ie452420448eec1d13edaf62e548df0b9e2cbbe4b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/766479
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/datasource.go b/internal/datasource.go
index bf47215..e844143 100644
--- a/internal/datasource.go
+++ b/internal/datasource.go
@@ -29,24 +29,24 @@
// GetImports returns a slice of import paths imported by the package
// specified by path and version.
GetImports(ctx context.Context, pkgPath, modulePath, version string) ([]string, error)
- // GetModuleInfo returns the ModuleInfo corresponding to modulePath and
+ // GetModuleInfo returns the LegacyModuleInfo corresponding to modulePath and
// version.
- GetModuleInfo(ctx context.Context, modulePath, version string) (*ModuleInfo, error)
+ GetModuleInfo(ctx context.Context, modulePath, version string) (*LegacyModuleInfo, error)
// GetPathInfo returns information about a path.
GetPathInfo(ctx context.Context, path, inModulePath, inVersion string) (outModulePath, outVersion string, isPackage bool, err error)
- // GetPseudoVersionsForModule returns ModuleInfo for all known
+ // GetPseudoVersionsForModule returns LegacyModuleInfo for all known
// pseudo-versions for the module corresponding to modulePath.
- GetPseudoVersionsForModule(ctx context.Context, modulePath string) ([]*ModuleInfo, error)
- // GetPseudoVersionsForModule returns ModuleInfo for all known
+ GetPseudoVersionsForModule(ctx context.Context, modulePath string) ([]*LegacyModuleInfo, error)
+ // GetPseudoVersionsForModule returns LegacyModuleInfo for all known
// pseudo-versions for any module containing a package with the given import
// path.
- GetPseudoVersionsForPackageSeries(ctx context.Context, pkgPath string) ([]*ModuleInfo, error)
- // GetTaggedVersionsForModule returns ModuleInfo for all known tagged
+ GetPseudoVersionsForPackageSeries(ctx context.Context, pkgPath string) ([]*LegacyModuleInfo, error)
+ // GetTaggedVersionsForModule returns LegacyModuleInfo for all known tagged
// versions for the module corresponding to modulePath.
- GetTaggedVersionsForModule(ctx context.Context, modulePath string) ([]*ModuleInfo, error)
- // GetTaggedVersionsForModule returns ModuleInfo for all known tagged
+ GetTaggedVersionsForModule(ctx context.Context, modulePath string) ([]*LegacyModuleInfo, error)
+ // GetTaggedVersionsForModule returns LegacyModuleInfo for all known tagged
// versions for any module containing a package with the given import path.
- GetTaggedVersionsForPackageSeries(ctx context.Context, pkgPath string) ([]*ModuleInfo, error)
+ GetTaggedVersionsForPackageSeries(ctx context.Context, pkgPath string) ([]*LegacyModuleInfo, error)
// GetVersionMap returns the VersionMap corresponding to the provided modulePath and requestedVersion.
GetVersionMap(ctx context.Context, modulePath, requestedVersion string) (*VersionMap, error)
// GetStdlibPathsWithSuffix returns standard library paths with the given suffix.
diff --git a/internal/discovery.go b/internal/discovery.go
index e7f390e..a14d592 100644
--- a/internal/discovery.go
+++ b/internal/discovery.go
@@ -30,8 +30,8 @@
UnknownModulePath = "unknownModulePath"
)
-// ModuleInfo holds metadata associated with a module.
-type ModuleInfo struct {
+// LegacyModuleInfo holds metadata associated with a module.
+type LegacyModuleInfo struct {
ModulePath string
Version string
CommitTime time.Time
@@ -67,7 +67,7 @@
// The module paths "a/b" and "a/b/v2" both have series path "a/b".
// The module paths "gopkg.in/yaml.v1" and "gopkg.in/yaml.v2" both have series
// path "gopkg.in/yaml".
-func (v *ModuleInfo) SeriesPath() string {
+func (v *LegacyModuleInfo) SeriesPath() string {
return SeriesPathForModule(v.ModulePath)
}
@@ -89,7 +89,7 @@
// A Module is a specific, reproducible build of a module.
type Module struct {
- ModuleInfo
+ LegacyModuleInfo
// Licenses holds all licenses within this module version, including those
// that may be contained in nested subdirectories.
Licenses []*licenses.License
@@ -102,7 +102,7 @@
// information.
type VersionedDirectory struct {
DirectoryNew
- ModuleInfo
+ LegacyModuleInfo
}
// DirectoryNew is a folder in a module version, and all of the packages
@@ -239,9 +239,9 @@
//
// FieldSet bits are unique across the entire project, because some types are
// concatenations (via embedding) of others. For example, a
-// LegacyVersionedPackage contains the fields of both a ModuleInfo and a
+// LegacyVersionedPackage contains the fields of both a LegacyModuleInfo and a
// LegacyPackage, so we can't use the
-// same bits for both ModuleInfo's LegacyReadmeContents field and
+// same bits for both LegacyModuleInfo's LegacyReadmeContents field and
// LegacyPackage's DocumentationHTML field.
type FieldSet int64
@@ -265,7 +265,7 @@
// LegacyDirectory represents a folder in a module version, and all of the
// packages inside that folder.
type LegacyDirectory struct {
- ModuleInfo
+ LegacyModuleInfo
Path string
Packages []*LegacyPackage
}
@@ -294,5 +294,5 @@
// information.
type LegacyVersionedPackage struct {
LegacyPackage
- ModuleInfo
+ LegacyModuleInfo
}
diff --git a/internal/fetch/fetch.go b/internal/fetch/fetch.go
index 8928991..ec5208f 100644
--- a/internal/fetch/fetch.go
+++ b/internal/fetch/fetch.go
@@ -187,7 +187,7 @@
break
}
return &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: modulePath,
Version: resolvedVersion,
CommitTime: commitTime,
diff --git a/internal/fetch/fetchdata_test.go b/internal/fetch/fetchdata_test.go
index 24d4d73..ad1bd40 100644
--- a/internal/fetch/fetchdata_test.go
+++ b/internal/fetch/fetchdata_test.go
@@ -31,7 +31,7 @@
},
fr: &FetchResult{
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "github.com/basic",
LegacyReadmeFilePath: "README.md",
LegacyReadmeContents: "THIS IS A README",
@@ -98,7 +98,7 @@
},
fr: &FetchResult{
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "github.com/my/module",
HasGoMod: true,
LegacyReadmeFilePath: "README.md",
@@ -162,7 +162,7 @@
},
fr: &FetchResult{
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "no.mod/module",
HasGoMod: false,
},
@@ -224,7 +224,7 @@
fr: &FetchResult{
Status: derrors.ToHTTPStatus(derrors.HasIncompletePackages),
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "bad.mod/module",
},
Directories: []*internal.DirectoryNew{
@@ -286,7 +286,7 @@
fr: &FetchResult{
Status: derrors.ToHTTPStatus(derrors.HasIncompletePackages),
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "build.constraints/module",
HasGoMod: false,
},
@@ -371,7 +371,7 @@
},
fr: &FetchResult{
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "nonredistributable.mod/module",
LegacyReadmeFilePath: "README.md",
LegacyReadmeContents: "README FILE FOR TESTING.",
@@ -440,7 +440,7 @@
fr: &FetchResult{
Status: derrors.ToHTTPStatus(derrors.HasIncompletePackages),
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "bad.import.path.com",
},
Directories: []*internal.DirectoryNew{
@@ -505,7 +505,7 @@
fr: &FetchResult{
GoModPath: "doc.test",
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "doc.test",
HasGoMod: false,
},
@@ -547,7 +547,7 @@
},
fr: &FetchResult{
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "github.com/my/module/js",
LegacyReadmeFilePath: "README.md",
LegacyReadmeContents: "THIS IS A README",
@@ -597,7 +597,7 @@
},
fr: &FetchResult{
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "std",
Version: "v1.12.5",
CommitTime: stdlib.TestCommitTime,
@@ -752,7 +752,7 @@
fr: &FetchResult{
GoModPath: path,
Module: &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: path,
HasGoMod: false,
},
diff --git a/internal/frontend/directory.go b/internal/frontend/directory.go
index e662241..397cf8e 100644
--- a/internal/frontend/directory.go
+++ b/internal/frontend/directory.go
@@ -83,7 +83,7 @@
// the module path. However, on the package and directory view's
// "Subdirectories" tab, we do not want to include packages whose import paths
// are the same as the dirPath.
-func fetchDirectoryDetails(ctx context.Context, ds internal.DataSource, dirPath string, mi *internal.ModuleInfo,
+func fetchDirectoryDetails(ctx context.Context, ds internal.DataSource, dirPath string, mi *internal.LegacyModuleInfo,
licmetas []*licenses.Metadata, includeDirPath bool) (_ *Directory, err error) {
defer derrors.Wrap(&err, "s.ds.fetchDirectoryDetails(%q, %q, %q, %v)", dirPath, mi.ModulePath, mi.Version, licmetas)
@@ -97,18 +97,18 @@
return nil, err
}
return createDirectory(&internal.LegacyDirectory{
- ModuleInfo: *mi,
- Path: dirPath,
- Packages: pkgs,
+ LegacyModuleInfo: *mi,
+ Path: dirPath,
+ Packages: pkgs,
}, licmetas, includeDirPath)
}
dbDir, err := ds.GetDirectory(ctx, dirPath, mi.ModulePath, mi.Version, internal.AllFields)
if errors.Is(err, derrors.NotFound) {
return createDirectory(&internal.LegacyDirectory{
- ModuleInfo: *mi,
- Path: dirPath,
- Packages: nil,
+ LegacyModuleInfo: *mi,
+ Path: dirPath,
+ Packages: nil,
}, licmetas, includeDirPath)
}
if err != nil {
@@ -134,7 +134,7 @@
if !includeDirPath && pkg.Path == dbDir.Path {
continue
}
- newPkg, err := createPackage(pkg, &dbDir.ModuleInfo, false)
+ newPkg, err := createPackage(pkg, &dbDir.LegacyModuleInfo, false)
if err != nil {
return nil, err
}
@@ -147,7 +147,7 @@
}
packages = append(packages, newPkg)
}
- mod := createModule(&dbDir.ModuleInfo, licmetas, false)
+ mod := createModule(&dbDir.LegacyModuleInfo, licmetas, false)
sort.Slice(packages, func(i, j int) bool { return packages[i].Path < packages[j].Path })
return &Directory{
diff --git a/internal/frontend/directory_test.go b/internal/frontend/directory_test.go
index 58f355f..c18d7fe 100644
--- a/internal/frontend/directory_test.go
+++ b/internal/frontend/directory_test.go
@@ -29,7 +29,7 @@
checkDirectory := func(got *Directory, dirPath, modulePath, version string, suffixes []string) {
t.Helper()
- mi := sample.ModuleInfo(modulePath, version)
+ mi := sample.LegacyModuleInfo(modulePath, version)
var wantPkgs []*Package
for _, suffix := range suffixes {
sp := sample.LegacyPackage(modulePath, suffix)
diff --git a/internal/frontend/header.go b/internal/frontend/header.go
index e31f7d4..7a71141 100644
--- a/internal/frontend/header.go
+++ b/internal/frontend/header.go
@@ -49,7 +49,7 @@
// latestRequested indicates whether the user requested the latest
// version of the package. If so, the returned Package.URL will have the
// structure /<path> instead of /<path>@<version>.
-func createPackage(pkg *internal.LegacyPackage, mi *internal.ModuleInfo, latestRequested bool) (_ *Package, err error) {
+func createPackage(pkg *internal.LegacyPackage, mi *internal.LegacyModuleInfo, latestRequested bool) (_ *Package, err error) {
defer derrors.Wrap(&err, "createPackage(%v, %v)", pkg, mi)
if pkg == nil || mi == nil {
@@ -99,7 +99,7 @@
}
}
- m := createModule(&vdir.ModuleInfo, modLicenses, latestRequested)
+ m := createModule(&vdir.LegacyModuleInfo, modLicenses, latestRequested)
urlVersion := m.LinkVersion
if latestRequested {
urlVersion = internal.LatestVersion
@@ -121,7 +121,7 @@
// latestRequested indicates whether the user requested the latest
// version of the package. If so, the returned Module.URL will have the
// structure /<path> instead of /<path>@<version>.
-func createModule(mi *internal.ModuleInfo, licmetas []*licenses.Metadata, latestRequested bool) *Module {
+func createModule(mi *internal.LegacyModuleInfo, licmetas []*licenses.Metadata, latestRequested bool) *Module {
urlVersion := linkVersion(mi.Version, mi.ModulePath)
if latestRequested {
urlVersion = internal.LatestVersion
diff --git a/internal/frontend/header_test.go b/internal/frontend/header_test.go
index 5a38714..2eb42bf 100644
--- a/internal/frontend/header_test.go
+++ b/internal/frontend/header_test.go
@@ -96,8 +96,8 @@
func TestCreatePackageHeader(t *testing.T) {
vpkg := func(modulePath, suffix, name string) *internal.LegacyVersionedPackage {
vp := &internal.LegacyVersionedPackage{
- ModuleInfo: *sample.ModuleInfo(modulePath, sample.VersionString),
- LegacyPackage: *sample.LegacyPackage(modulePath, suffix),
+ LegacyModuleInfo: *sample.LegacyModuleInfo(modulePath, sample.VersionString),
+ LegacyPackage: *sample.LegacyPackage(modulePath, suffix),
}
if name != "" {
vp.LegacyPackage.Name = name
@@ -138,7 +138,7 @@
},
} {
t.Run(tc.label, func(t *testing.T) {
- got, err := createPackage(&tc.pkg.LegacyPackage, &tc.pkg.ModuleInfo, false)
+ got, err := createPackage(&tc.pkg.LegacyPackage, &tc.pkg.LegacyModuleInfo, false)
if err != nil {
t.Fatal(err)
}
diff --git a/internal/frontend/imports_test.go b/internal/frontend/imports_test.go
index 2d8510b..cfe3e03 100644
--- a/internal/frontend/imports_test.go
+++ b/internal/frontend/imports_test.go
@@ -63,7 +63,7 @@
module.LegacyPackages[0].Path, module.Version, got, err, tc.wantDetails)
}
- tc.wantDetails.ModulePath = module.ModuleInfo.ModulePath
+ tc.wantDetails.ModulePath = module.LegacyModuleInfo.ModulePath
if diff := cmp.Diff(tc.wantDetails, got); diff != "" {
t.Errorf("fetchImportsDetails(ctx, %q, %q) mismatch (-want +got):\n%s", module.LegacyPackages[0].Path, module.Version, diff)
}
@@ -76,8 +76,8 @@
// version.
func firstVersionedPackage(m *internal.Module) *internal.LegacyVersionedPackage {
return &internal.LegacyVersionedPackage{
- LegacyPackage: *m.LegacyPackages[0],
- ModuleInfo: m.ModuleInfo,
+ LegacyPackage: *m.LegacyPackages[0],
+ LegacyModuleInfo: m.LegacyModuleInfo,
}
}
@@ -152,7 +152,7 @@
tc.pkg.Path, got, err, tc.wantDetails)
}
- tc.wantDetails.ModulePath = vp.ModuleInfo.ModulePath
+ tc.wantDetails.ModulePath = vp.LegacyModuleInfo.ModulePath
if diff := cmp.Diff(tc.wantDetails, got); diff != "" {
t.Errorf("fetchImportedByDetails(ctx, db, %q) mismatch (-want +got):\n%s", tc.pkg.Path, diff)
}
diff --git a/internal/frontend/latest_version.go b/internal/frontend/latest_version.go
index 4bc09a5..3a3026f 100644
--- a/internal/frontend/latest_version.go
+++ b/internal/frontend/latest_version.go
@@ -32,7 +32,7 @@
func (s *Server) latestVersion(ctx context.Context, packagePath, modulePath, pageType string) (_ string, err error) {
defer derrors.Wrap(&err, "latestVersion(ctx, %q, %q)", modulePath, packagePath)
- var mi *internal.ModuleInfo
+ var mi *internal.LegacyModuleInfo
switch pageType {
case "mod":
mi, err = s.ds.GetModuleInfo(ctx, modulePath, internal.LatestVersion)
@@ -44,7 +44,7 @@
if err != nil {
return "", err
}
- mi = &pkg.ModuleInfo
+ mi = &pkg.LegacyModuleInfo
default:
// For directories we don't have a well-defined latest version.
return "", nil
diff --git a/internal/frontend/module.go b/internal/frontend/module.go
index 3d4004c..e2f9d15 100644
--- a/internal/frontend/module.go
+++ b/internal/frontend/module.go
@@ -71,7 +71,7 @@
return pathNotFoundError(ctx, "module", modulePath, requestedVersion)
}
-func (s *Server) serveModulePageWithModule(ctx context.Context, w http.ResponseWriter, r *http.Request, mi *internal.ModuleInfo, requestedVersion string) error {
+func (s *Server) serveModulePageWithModule(ctx context.Context, w http.ResponseWriter, r *http.Request, mi *internal.LegacyModuleInfo, requestedVersion string) error {
licenses, err := s.ds.GetModuleLicenses(ctx, mi.ModulePath, mi.Version)
if err != nil {
return err
diff --git a/internal/frontend/overview.go b/internal/frontend/overview.go
index 583a4be..4a05917 100644
--- a/internal/frontend/overview.go
+++ b/internal/frontend/overview.go
@@ -34,7 +34,7 @@
// versionedLinks says whether the constructed URLs should have versions.
// constructOverviewDetails uses the given version to construct an OverviewDetails.
-func constructOverviewDetails(mi *internal.ModuleInfo, isRedistributable bool, versionedLinks bool) *OverviewDetails {
+func constructOverviewDetails(mi *internal.LegacyModuleInfo, isRedistributable bool, versionedLinks bool) *OverviewDetails {
var lv string
if versionedLinks {
lv = linkVersion(mi.Version, mi.ModulePath)
@@ -56,7 +56,7 @@
// fetchPackageOverviewDetails uses data for the given package to return an OverviewDetails.
func fetchPackageOverviewDetails(pkg *internal.LegacyVersionedPackage, versionedLinks bool) *OverviewDetails {
- od := constructOverviewDetails(&pkg.ModuleInfo, pkg.LegacyPackage.IsRedistributable, versionedLinks)
+ od := constructOverviewDetails(&pkg.LegacyModuleInfo, pkg.LegacyPackage.IsRedistributable, versionedLinks)
od.PackageSourceURL = pkg.SourceInfo.DirectoryURL(packageSubdir(pkg.Path, pkg.ModulePath))
if !pkg.LegacyPackage.IsRedistributable {
od.Redistributable = false
@@ -66,7 +66,7 @@
// fetchPackageOverviewDetailsNew uses data for the given versioned directory to return an OverviewDetails.
func fetchPackageOverviewDetailsNew(vdir *internal.VersionedDirectory, versionedLinks bool) *OverviewDetails {
- od := constructOverviewDetails(&vdir.ModuleInfo, vdir.DirectoryNew.IsRedistributable, versionedLinks)
+ od := constructOverviewDetails(&vdir.LegacyModuleInfo, vdir.DirectoryNew.IsRedistributable, versionedLinks)
od.PackageSourceURL = vdir.SourceInfo.DirectoryURL(packageSubdir(vdir.Path, vdir.ModulePath))
if !vdir.DirectoryNew.IsRedistributable {
od.Redistributable = false
@@ -89,7 +89,7 @@
// readmeHTML sanitizes readmeContents based on bluemondy.UGCPolicy and returns
// a template.HTML. If readmeFilePath indicates that this is a markdown file,
// it will also render the markdown contents using blackfriday.
-func readmeHTML(mi *internal.ModuleInfo) template.HTML {
+func readmeHTML(mi *internal.LegacyModuleInfo) template.HTML {
if len(mi.LegacyReadmeContents) == 0 {
return ""
}
@@ -138,7 +138,7 @@
// image files inside the repository. As the discovery site doesn't host the
// full repository content, in order for the image to render, we need to
// convert the relative path to an absolute URL to a hosted image.
-func translateRelativeLink(node *blackfriday.Node, mi *internal.ModuleInfo) {
+func translateRelativeLink(node *blackfriday.Node, mi *internal.LegacyModuleInfo) {
destURL, err := url.Parse(string(node.LinkData.Destination))
if err != nil || destURL.IsAbs() {
return
diff --git a/internal/frontend/overview_test.go b/internal/frontend/overview_test.go
index 76b405a..a5dc3aa 100644
--- a/internal/frontend/overview_test.go
+++ b/internal/frontend/overview_test.go
@@ -45,7 +45,7 @@
t.Fatal(err)
}
- got := constructOverviewDetails(&tc.module.ModuleInfo, true, true)
+ got := constructOverviewDetails(&tc.module.LegacyModuleInfo, true, true)
if diff := cmp.Diff(tc.wantDetails, got); diff != "" {
t.Errorf("constructOverviewDetails(%q, %q) mismatch (-want +got):\n%s", tc.module.LegacyPackages[0].Path, tc.module.Version, diff)
}
@@ -65,7 +65,7 @@
Path: "github.com/u/m/p",
IsRedistributable: true,
},
- ModuleInfo: *sample.ModuleInfo("github.com/u/m", "v1.2.3"),
+ LegacyModuleInfo: *sample.LegacyModuleInfo("github.com/u/m", "v1.2.3"),
},
versionedLinks: true,
want: &OverviewDetails{
@@ -85,7 +85,7 @@
Path: "github.com/u/m/p",
IsRedistributable: true,
},
- ModuleInfo: *sample.ModuleInfo("github.com/u/m", "v1.2.3"),
+ LegacyModuleInfo: *sample.LegacyModuleInfo("github.com/u/m", "v1.2.3"),
},
versionedLinks: false,
want: &OverviewDetails{
@@ -105,7 +105,7 @@
Path: "github.com/u/m/p",
IsRedistributable: false,
},
- ModuleInfo: *sample.ModuleInfo("github.com/u/m", "v1.2.3"),
+ LegacyModuleInfo: *sample.LegacyModuleInfo("github.com/u/m", "v1.2.3"),
},
versionedLinks: true,
want: &OverviewDetails{
@@ -129,12 +129,12 @@
func TestReadmeHTML(t *testing.T) {
testCases := []struct {
name string
- mi *internal.ModuleInfo
+ mi *internal.LegacyModuleInfo
want template.HTML
}{
{
name: "valid markdown readme",
- mi: &internal.ModuleInfo{
+ mi: &internal.LegacyModuleInfo{
LegacyReadmeFilePath: "README.md",
LegacyReadmeContents: "This package collects pithy sayings.\n\n" +
"It's part of a demonstration of\n" +
@@ -146,7 +146,7 @@
},
{
name: "valid markdown readme with alternative case and extension",
- mi: &internal.ModuleInfo{
+ mi: &internal.LegacyModuleInfo{
LegacyReadmeFilePath: "README.MARKDOWN",
LegacyReadmeContents: "This package collects pithy sayings.\n\n" +
"It's part of a demonstration of\n" +
@@ -158,7 +158,7 @@
},
{
name: "not markdown readme",
- mi: &internal.ModuleInfo{
+ mi: &internal.LegacyModuleInfo{
LegacyReadmeFilePath: "README.rst",
LegacyReadmeContents: "This package collects pithy sayings.\n\n" +
"It's part of a demonstration of\n" +
@@ -168,12 +168,12 @@
},
{
name: "empty readme",
- mi: &internal.ModuleInfo{},
+ mi: &internal.LegacyModuleInfo{},
want: "",
},
{
name: "sanitized readme",
- mi: &internal.ModuleInfo{
+ mi: &internal.LegacyModuleInfo{
LegacyReadmeFilePath: "README",
LegacyReadmeContents: `<a onblur="alert(secret)" href="http://www.google.com">Google</a>`,
},
@@ -181,7 +181,7 @@
},
{
name: "relative image markdown is made absolute for GitHub",
- mi: &internal.ModuleInfo{
+ mi: &internal.LegacyModuleInfo{
LegacyReadmeFilePath: "README.md",
LegacyReadmeContents: "![Go logo](doc/logo.png)",
SourceInfo: source.NewGitHubInfo("http://github.com/golang/go", "", "master"),
@@ -190,7 +190,7 @@
},
{
name: "relative image markdown is made absolute for GitLab",
- mi: &internal.ModuleInfo{
+ mi: &internal.LegacyModuleInfo{
LegacyReadmeFilePath: "README.md",
LegacyReadmeContents: "![Gitaly benchmark timings.](doc/img/rugged-new-timings.png)",
SourceInfo: source.NewGitLabInfo("http://gitlab.com/gitlab-org/gitaly", "", "v1.0.0"),
@@ -199,7 +199,7 @@
},
{
name: "relative image markdown is left alone for unknown origins",
- mi: &internal.ModuleInfo{
+ mi: &internal.LegacyModuleInfo{
LegacyReadmeFilePath: "README.md",
LegacyReadmeContents: "![Go logo](doc/logo.png)",
},
@@ -207,7 +207,7 @@
},
{
name: "module versions are referenced in relative images",
- mi: &internal.ModuleInfo{
+ mi: &internal.LegacyModuleInfo{
LegacyReadmeFilePath: "README.md",
LegacyReadmeContents: "![Hugo logo](doc/logo.png)",
Version: "v0.56.3",
@@ -218,7 +218,7 @@
},
{
name: "image URLs relative to README directory",
- mi: &internal.ModuleInfo{
+ mi: &internal.LegacyModuleInfo{
LegacyReadmeFilePath: "dir/sub/README.md",
LegacyReadmeContents: "![alt](img/thing.png)",
Version: "v1.2.3",
@@ -229,7 +229,7 @@
},
{
name: "non-image links relative to README directory",
- mi: &internal.ModuleInfo{
+ mi: &internal.LegacyModuleInfo{
LegacyReadmeFilePath: "dir/sub/README.md",
LegacyReadmeContents: "[something](doc/thing.md)",
Version: "v1.2.3",
diff --git a/internal/frontend/package.go b/internal/frontend/package.go
index ed1694f..1cc20b6 100644
--- a/internal/frontend/package.go
+++ b/internal/frontend/package.go
@@ -106,7 +106,7 @@
derrors.Wrap(&err, "servePackagePageWithPackage(w, r, %q, %q, %q)", pkg.Path, pkg.ModulePath, requestedVersion)
}
}()
- pkgHeader, err := createPackage(&pkg.LegacyPackage, &pkg.ModuleInfo, requestedVersion == internal.LatestVersion)
+ pkgHeader, err := createPackage(&pkg.LegacyPackage, &pkg.LegacyModuleInfo, requestedVersion == internal.LatestVersion)
if err != nil {
return fmt.Errorf("creating package header for %s@%s: %v", pkg.Path, pkg.Version, err)
}
diff --git a/internal/frontend/search_test.go b/internal/frontend/search_test.go
index 9a55142..fb1f449 100644
--- a/internal/frontend/search_test.go
+++ b/internal/frontend/search_test.go
@@ -24,7 +24,7 @@
var (
now = sample.NowTruncated()
moduleFoo = &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "github.com/mod/foo",
Version: "v1.0.0",
LegacyReadmeContents: "readme",
@@ -43,7 +43,7 @@
},
}
moduleBar = &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "github.com/mod/bar",
Version: "v1.0.0",
LegacyReadmeContents: "readme",
diff --git a/internal/frontend/tabs.go b/internal/frontend/tabs.go
index 81fec46..b123213 100644
--- a/internal/frontend/tabs.go
+++ b/internal/frontend/tabs.go
@@ -148,7 +148,7 @@
case "versions":
return fetchPackageVersionsDetails(ctx, ds, pkg.Path, pkg.V1Path, pkg.ModulePath)
case "subdirectories":
- return fetchDirectoryDetails(ctx, ds, pkg.Path, &pkg.ModuleInfo, pkg.Licenses, false)
+ return fetchDirectoryDetails(ctx, ds, pkg.Path, &pkg.LegacyModuleInfo, pkg.Licenses, false)
case "imports":
return fetchImportsDetails(ctx, ds, pkg.Path, pkg.ModulePath, pkg.Version)
case "importedby":
@@ -170,7 +170,7 @@
case "versions":
return fetchPackageVersionsDetails(ctx, ds, vdir.Path, vdir.V1Path, vdir.ModulePath)
case "subdirectories":
- return fetchDirectoryDetails(ctx, ds, vdir.Path, &vdir.ModuleInfo, vdir.Licenses, false)
+ return fetchDirectoryDetails(ctx, ds, vdir.Path, &vdir.LegacyModuleInfo, vdir.Licenses, false)
case "imports":
return fetchImportsDetails(ctx, ds, vdir.Path, vdir.ModulePath, vdir.Version)
case "importedby":
@@ -189,7 +189,7 @@
// fetchDetailsForModule returns tab details by delegating to the correct detail
// handler.
-func fetchDetailsForModule(ctx context.Context, r *http.Request, tab string, ds internal.DataSource, mi *internal.ModuleInfo, licenses []*licenses.License) (interface{}, error) {
+func fetchDetailsForModule(ctx context.Context, r *http.Request, tab string, ds internal.DataSource, mi *internal.LegacyModuleInfo, licenses []*licenses.License) (interface{}, error) {
switch tab {
case "packages":
return fetchDirectoryDetails(ctx, ds, mi.ModulePath, mi, licensesToMetadatas(licenses), true)
@@ -209,7 +209,7 @@
func constructDetailsForDirectory(r *http.Request, tab string, dir *internal.LegacyDirectory, licenses []*licenses.License) (interface{}, error) {
switch tab {
case "overview":
- return constructOverviewDetails(&dir.ModuleInfo, dir.ModuleInfo.IsRedistributable, urlIsVersioned(r.URL)), nil
+ return constructOverviewDetails(&dir.LegacyModuleInfo, dir.LegacyModuleInfo.IsRedistributable, urlIsVersioned(r.URL)), nil
case "subdirectories":
// Ideally we would just use fetchDirectoryDetails here so that it
// follows the same code path as fetchDetailsForModule and
diff --git a/internal/frontend/versions.go b/internal/frontend/versions.go
index 3ee148a..c365acf 100644
--- a/internal/frontend/versions.go
+++ b/internal/frontend/versions.go
@@ -63,7 +63,7 @@
// fetchModuleVersionsDetails builds a version hierarchy for module versions
// with the same series path as the given version.
-func fetchModuleVersionsDetails(ctx context.Context, ds internal.DataSource, mi *internal.ModuleInfo) (*VersionsDetails, error) {
+func fetchModuleVersionsDetails(ctx context.Context, ds internal.DataSource, mi *internal.LegacyModuleInfo) (*VersionsDetails, error) {
versions, err := ds.GetTaggedVersionsForModule(ctx, mi.ModulePath)
if err != nil {
return nil, err
@@ -76,7 +76,7 @@
return nil, err
}
}
- linkify := func(m *internal.ModuleInfo) string {
+ linkify := func(m *internal.LegacyModuleInfo) string {
return constructModuleURL(m.ModulePath, linkVersion(m.Version, m.ModulePath))
}
return buildVersionDetails(mi.ModulePath, versions, linkify), nil
@@ -98,7 +98,7 @@
}
}
- var filteredVersions []*internal.ModuleInfo
+ var filteredVersions []*internal.LegacyModuleInfo
// TODO(rfindley): remove this filtering, as it should not be necessary and
// is probably a relic of earlier version query implementations.
for _, v := range versions {
@@ -109,7 +109,7 @@
}
}
- linkify := func(mi *internal.ModuleInfo) string {
+ linkify := func(mi *internal.LegacyModuleInfo) string {
// Here we have only version information, but need to construct the full
// import path of the package corresponding to this version.
var versionPath string
@@ -135,7 +135,7 @@
// 3) Join with the versioned module path foo.com/bar/v2 to get
// foo.com/bar/v2/baz.
// ...being careful about slashes along the way.
-func pathInVersion(v1Path string, mi *internal.ModuleInfo) string {
+func pathInVersion(v1Path string, mi *internal.LegacyModuleInfo) string {
suffix := strings.TrimPrefix(strings.TrimPrefix(v1Path, mi.SeriesPath()), "/")
if suffix == "" {
return mi.ModulePath
@@ -147,7 +147,7 @@
// versions tab, organizing major versions into those that have the same module
// path as the package version under consideration, and those that don't. The
// given versions MUST be sorted first by module path and then by semver.
-func buildVersionDetails(currentModulePath string, modInfos []*internal.ModuleInfo, linkify func(v *internal.ModuleInfo) string) *VersionsDetails {
+func buildVersionDetails(currentModulePath string, modInfos []*internal.LegacyModuleInfo, linkify func(v *internal.LegacyModuleInfo) string) *VersionsDetails {
// lists organizes versions by VersionListKey. Note that major version isn't
// sufficient as a key: there are packages contained in the same major
diff --git a/internal/frontend/versions_test.go b/internal/frontend/versions_test.go
index 1e80f42..4b99506 100644
--- a/internal/frontend/versions_test.go
+++ b/internal/frontend/versions_test.go
@@ -58,8 +58,8 @@
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel()
- info1 := sample.ModuleInfo(modulePath1, "v1.2.1")
- info2 := sample.ModuleInfo(modulePath2, "v2.2.1-alpha.1")
+ info1 := sample.LegacyModuleInfo(modulePath1, "v1.2.1")
+ info2 := sample.LegacyModuleInfo(modulePath2, "v2.2.1-alpha.1")
makeList := func(path, major string, versions []string) *VersionList {
return &VersionList{
VersionListKey: VersionListKey{ModulePath: path, Major: major},
@@ -71,7 +71,7 @@
for _, tc := range []struct {
name string
- info *internal.ModuleInfo
+ info *internal.LegacyModuleInfo
modules []*internal.Module
wantDetails *VersionsDetails
}{
@@ -162,16 +162,16 @@
)
pkg1 := &internal.LegacyVersionedPackage{
- ModuleInfo: *sample.ModuleInfo(modulePath1, "v1.2.1"),
- LegacyPackage: *sample.LegacyPackage(modulePath1, sample.Suffix),
+ LegacyModuleInfo: *sample.LegacyModuleInfo(modulePath1, "v1.2.1"),
+ LegacyPackage: *sample.LegacyPackage(modulePath1, sample.Suffix),
}
pkg2 := &internal.LegacyVersionedPackage{
- ModuleInfo: *sample.ModuleInfo(modulePath2, "v2.2.1-alpha.1"),
- LegacyPackage: *sample.LegacyPackage(modulePath2, sample.Suffix),
+ LegacyModuleInfo: *sample.LegacyModuleInfo(modulePath2, "v2.2.1-alpha.1"),
+ LegacyPackage: *sample.LegacyPackage(modulePath2, sample.Suffix),
}
nethttpPkg := &internal.LegacyVersionedPackage{
- ModuleInfo: *sample.ModuleInfo("std", "v1.12.5"),
- LegacyPackage: *sample.LegacyPackage("std", "net/http"),
+ LegacyModuleInfo: *sample.LegacyModuleInfo("std", "v1.12.5"),
+ LegacyPackage: *sample.LegacyPackage("std", "net/http"),
}
makeList := func(pkgPath, modulePath, major string, versions []string) *VersionList {
return &VersionList{
@@ -291,9 +291,9 @@
}
for _, test := range tests {
- mi := sample.ModuleInfo(test.modulePath, sample.VersionString)
+ mi := sample.LegacyModuleInfo(test.modulePath, sample.VersionString)
if got := pathInVersion(test.v1Path, mi); got != test.want {
- t.Errorf("pathInVersion(%q, ModuleInfo{...ModulePath:%q}) = %s, want %v",
+ t.Errorf("pathInVersion(%q, LegacyModuleInfo{...ModulePath:%q}) = %s, want %v",
test.v1Path, mi.ModulePath, got, test.want)
}
}
diff --git a/internal/postgres/details.go b/internal/postgres/details.go
index b6763f1..c075582 100644
--- a/internal/postgres/details.go
+++ b/internal/postgres/details.go
@@ -73,21 +73,21 @@
// GetTaggedVersionsForPackageSeries returns a list of tagged versions sorted in
// descending semver order. This list includes tagged versions of packages that
// have the same v1path.
-func (db *DB) GetTaggedVersionsForPackageSeries(ctx context.Context, pkgPath string) ([]*internal.ModuleInfo, error) {
+func (db *DB) GetTaggedVersionsForPackageSeries(ctx context.Context, pkgPath string) ([]*internal.LegacyModuleInfo, error) {
return getPackageVersions(ctx, db, pkgPath, []version.Type{version.TypeRelease, version.TypePrerelease})
}
// GetPseudoVersionsForPackageSeries returns the 10 most recent from a list of
// pseudo-versions sorted in descending semver order. This list includes
// pseudo-versions of packages that have the same v1path.
-func (db *DB) GetPseudoVersionsForPackageSeries(ctx context.Context, pkgPath string) ([]*internal.ModuleInfo, error) {
+func (db *DB) GetPseudoVersionsForPackageSeries(ctx context.Context, pkgPath string) ([]*internal.LegacyModuleInfo, error) {
return getPackageVersions(ctx, db, pkgPath, []version.Type{version.TypePseudo})
}
// getPackageVersions returns a list of versions sorted in descending semver
// order. The version types included in the list are specified by a list of
// VersionTypes.
-func getPackageVersions(ctx context.Context, db *DB, pkgPath string, versionTypes []version.Type) (_ []*internal.ModuleInfo, err error) {
+func getPackageVersions(ctx context.Context, db *DB, pkgPath string, versionTypes []version.Type) (_ []*internal.LegacyModuleInfo, err error) {
defer derrors.Wrap(&err, "DB.getPackageVersions(ctx, db, %q, %v)", pkgPath, versionTypes)
baseQuery := `
@@ -126,9 +126,9 @@
}
defer rows.Close()
- var versionHistory []*internal.ModuleInfo
+ var versionHistory []*internal.LegacyModuleInfo
for rows.Next() {
- var mi internal.ModuleInfo
+ var mi internal.LegacyModuleInfo
if err := rows.Scan(&mi.ModulePath, &mi.Version, &mi.CommitTime); err != nil {
return nil, fmt.Errorf("row.Scan(): %v", err)
}
@@ -154,20 +154,20 @@
// GetTaggedVersionsForModule returns a list of tagged versions sorted in
// descending semver order.
-func (db *DB) GetTaggedVersionsForModule(ctx context.Context, modulePath string) ([]*internal.ModuleInfo, error) {
+func (db *DB) GetTaggedVersionsForModule(ctx context.Context, modulePath string) ([]*internal.LegacyModuleInfo, error) {
return getModuleVersions(ctx, db, modulePath, []version.Type{version.TypeRelease, version.TypePrerelease})
}
// GetPseudoVersionsForModule returns the 10 most recent from a list of
// pseudo-versions sorted in descending semver order.
-func (db *DB) GetPseudoVersionsForModule(ctx context.Context, modulePath string) ([]*internal.ModuleInfo, error) {
+func (db *DB) GetPseudoVersionsForModule(ctx context.Context, modulePath string) ([]*internal.LegacyModuleInfo, error) {
return getModuleVersions(ctx, db, modulePath, []version.Type{version.TypePseudo})
}
// getModuleVersions returns a list of versions sorted in descending semver
// order. The version types included in the list are specified by a list of
// VersionTypes.
-func getModuleVersions(ctx context.Context, db *DB, modulePath string, versionTypes []version.Type) (_ []*internal.ModuleInfo, err error) {
+func getModuleVersions(ctx context.Context, db *DB, modulePath string, versionTypes []version.Type) (_ []*internal.LegacyModuleInfo, err error) {
// TODO(b/139530312): get information for parent modules.
defer derrors.Wrap(&err, "getModuleVersions(ctx, db, %q, %v)", modulePath, versionTypes)
@@ -189,9 +189,9 @@
queryEnd = `LIMIT 10;`
}
query := fmt.Sprintf(baseQuery, versionTypeExpr(versionTypes), queryEnd)
- var vinfos []*internal.ModuleInfo
+ var vinfos []*internal.LegacyModuleInfo
collect := func(rows *sql.Rows) error {
- var mi internal.ModuleInfo
+ var mi internal.LegacyModuleInfo
if err := rows.Scan(&mi.ModulePath, &mi.Version, &mi.CommitTime); err != nil {
return err
}
@@ -423,7 +423,7 @@
// GetModuleInfo fetches a Version from the database with the primary key
// (module_path, version).
-func (db *DB) GetModuleInfo(ctx context.Context, modulePath string, version string) (_ *internal.ModuleInfo, err error) {
+func (db *DB) GetModuleInfo(ctx context.Context, modulePath string, version string) (_ *internal.LegacyModuleInfo, err error) {
defer derrors.Wrap(&err, "GetModuleInfo(ctx, %q, %q)", modulePath, version)
query := `
@@ -458,7 +458,7 @@
}
var (
- mi internal.ModuleInfo
+ mi internal.LegacyModuleInfo
hasGoMod sql.NullBool
)
row := db.db.QueryRow(ctx, query, args...)
@@ -474,7 +474,7 @@
return &mi, nil
}
-func setHasGoMod(mi *internal.ModuleInfo, nb sql.NullBool) {
+func setHasGoMod(mi *internal.LegacyModuleInfo, nb sql.NullBool) {
// The safe default value for HasGoMod is true, because search will penalize modules that don't have one.
// This is temporary: when has_go_mod is fully populated, we'll make it NOT NULL.
mi.HasGoMod = true
diff --git a/internal/postgres/details_test.go b/internal/postgres/details_test.go
index 5ab23a4..b4b4ce2 100644
--- a/internal/postgres/details_test.go
+++ b/internal/postgres/details_test.go
@@ -81,7 +81,7 @@
if tc.wantIndex >= len(tc.modules) {
t.Fatal("wantIndex too large")
}
- wantVI := &tc.modules[tc.wantIndex].ModuleInfo
+ wantVI := &tc.modules[tc.wantIndex].LegacyModuleInfo
if diff := cmp.Diff(wantVI, gotVI, cmpopts.EquateEmpty(), cmp.AllowUnexported(source.Info{})); diff != "" {
t.Errorf("mismatch (-want +got):\n%s", diff)
}
@@ -193,7 +193,7 @@
name, path, modulePath string
numPseudo int
modules []*internal.Module
- wantTaggedVersions []*internal.ModuleInfo
+ wantTaggedVersions []*internal.LegacyModuleInfo
}{
{
name: "want_releases_and_prereleases_only",
@@ -201,7 +201,7 @@
modulePath: modulePath1,
numPseudo: 12,
modules: testModules,
- wantTaggedVersions: []*internal.ModuleInfo{
+ wantTaggedVersions: []*internal.LegacyModuleInfo{
{
ModulePath: modulePath2,
Version: "v2.1.0",
@@ -241,7 +241,7 @@
t.Run(tc.name, func(t *testing.T) {
defer ResetTestDB(testDB, t)
- var wantPseudoVersions []*internal.ModuleInfo
+ var wantPseudoVersions []*internal.LegacyModuleInfo
for i := 0; i < tc.numPseudo; i++ {
pseudo := fmt.Sprintf("v0.0.0-201806111833%02d-d8887717615a", i+1)
@@ -253,7 +253,7 @@
// GetPseudoVersions should only return the 10 most recent pseudo versions,
// if there are more than 10 in the database
if i < 10 {
- wantPseudoVersions = append(wantPseudoVersions, &internal.ModuleInfo{
+ wantPseudoVersions = append(wantPseudoVersions, &internal.LegacyModuleInfo{
ModulePath: modulePath1,
Version: fmt.Sprintf("v0.0.0-201806111833%02d-d8887717615a", tc.numPseudo-i),
CommitTime: sample.CommitTime,
diff --git a/internal/postgres/directory.go b/internal/postgres/directory.go
index f82508c..fbec3af 100644
--- a/internal/postgres/directory.go
+++ b/internal/postgres/directory.go
@@ -57,7 +57,7 @@
AND m.module_path = $2
AND m.version = $3;`
var (
- mi internal.ModuleInfo
+ mi internal.LegacyModuleInfo
dir internal.DirectoryNew
readme internal.Readme
doc internal.Documentation
@@ -125,8 +125,8 @@
}
return &internal.VersionedDirectory{
- ModuleInfo: mi,
- DirectoryNew: dir,
+ LegacyModuleInfo: mi,
+ DirectoryNew: dir,
}, nil
}
@@ -185,7 +185,7 @@
var (
packages []*internal.LegacyPackage
- mi = internal.ModuleInfo{LegacyReadmeContents: internal.StringFieldMissing}
+ mi = internal.LegacyModuleInfo{LegacyReadmeContents: internal.StringFieldMissing}
)
collect := func(rows *sql.Rows) error {
var (
@@ -243,9 +243,9 @@
return packages[i].Path < packages[j].Path
})
return &internal.LegacyDirectory{
- Path: dirPath,
- ModuleInfo: mi,
- Packages: packages,
+ Path: dirPath,
+ LegacyModuleInfo: mi,
+ Packages: packages,
}, nil
}
diff --git a/internal/postgres/directory_test.go b/internal/postgres/directory_test.go
index 7192207..544dde2 100644
--- a/internal/postgres/directory_test.go
+++ b/internal/postgres/directory_test.go
@@ -252,7 +252,7 @@
t.Fatal(err)
}
- mi := sample.ModuleInfo(tc.wantModulePath, tc.wantVersion)
+ mi := sample.LegacyModuleInfo(tc.wantModulePath, tc.wantVersion)
var wantPackages []*internal.LegacyPackage
for _, suffix := range tc.wantSuffixes {
pkg := sample.LegacyPackage(tc.wantModulePath, suffix)
@@ -264,9 +264,9 @@
})
wantDirectory := &internal.LegacyDirectory{
- ModuleInfo: *mi,
- Packages: wantPackages,
- Path: tc.dirPath,
+ LegacyModuleInfo: *mi,
+ Packages: wantPackages,
+ Path: tc.dirPath,
}
opts := []cmp.Option{
cmpopts.EquateEmpty(),
@@ -312,7 +312,7 @@
newVdir := func(path, modulePath, version string, readme *internal.Readme, pkg *internal.PackageNew) *internal.VersionedDirectory {
return &internal.VersionedDirectory{
- ModuleInfo: *sample.ModuleInfo(modulePath, version),
+ LegacyModuleInfo: *sample.LegacyModuleInfo(modulePath, version),
DirectoryNew: internal.DirectoryNew{
Path: path,
V1Path: path,
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go
index 99a5bf0..7e9f01f 100644
--- a/internal/postgres/insert_module_test.go
+++ b/internal/postgres/insert_module_test.go
@@ -88,7 +88,7 @@
if err != nil {
t.Fatal(err)
}
- if diff := cmp.Diff(test.module.ModuleInfo, *got, cmp.AllowUnexported(source.Info{})); diff != "" {
+ if diff := cmp.Diff(test.module.LegacyModuleInfo, *got, cmp.AllowUnexported(source.Info{})); diff != "" {
t.Fatalf("testDB.GetModuleInfo(%q, %q) mismatch (-want +got):\n%s", test.module.ModulePath, test.module.Version, diff)
}
@@ -117,12 +117,12 @@
t.Fatal(err)
}
want := internal.VersionedDirectory{
- DirectoryNew: *dir,
- ModuleInfo: test.module.ModuleInfo,
+ DirectoryNew: *dir,
+ LegacyModuleInfo: test.module.LegacyModuleInfo,
}
opts := cmp.Options{
- cmpopts.IgnoreFields(internal.ModuleInfo{}, "LegacyReadmeFilePath"),
- cmpopts.IgnoreFields(internal.ModuleInfo{}, "LegacyReadmeContents"),
+ cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "LegacyReadmeFilePath"),
+ cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "LegacyReadmeContents"),
cmpopts.IgnoreFields(licenses.Metadata{}, "Coverage"),
cmp.AllowUnexported(source.Info{}),
}
@@ -211,7 +211,7 @@
func TestPostgres_ReadAndWriteModuleOtherColumns(t *testing.T) {
// Verify that InsertModule correctly populates the columns in the versions
- // table that are not in the ModuleInfo struct.
+ // table that are not in the LegacyModuleInfo struct.
defer ResetTestDB(testDB, t)
ctx := context.Background()
diff --git a/internal/postgres/package.go b/internal/postgres/package.go
index 0c26f5b..e342dd4 100644
--- a/internal/postgres/package.go
+++ b/internal/postgres/package.go
@@ -141,7 +141,7 @@
&pkg.V1Path, pq.Array(&licenseTypes), pq.Array(&licensePaths), &pkg.LegacyPackage.IsRedistributable,
database.NullIsEmpty(&pkg.DocumentationHTML), &pkg.GOOS, &pkg.GOARCH, &pkg.Version,
&pkg.CommitTime, database.NullIsEmpty(&pkg.LegacyReadmeFilePath), database.NullIsEmpty(&pkg.LegacyReadmeContents),
- &pkg.ModulePath, &pkg.VersionType, jsonbScanner{&pkg.SourceInfo}, &pkg.ModuleInfo.IsRedistributable,
+ &pkg.ModulePath, &pkg.VersionType, jsonbScanner{&pkg.SourceInfo}, &pkg.LegacyModuleInfo.IsRedistributable,
&hasGoMod)
if err != nil {
if err == sql.ErrNoRows {
@@ -149,7 +149,7 @@
}
return nil, fmt.Errorf("row.Scan(): %v", err)
}
- setHasGoMod(&pkg.ModuleInfo, hasGoMod)
+ setHasGoMod(&pkg.LegacyModuleInfo, hasGoMod)
lics, err := zipLicenseMetadata(licenseTypes, licensePaths)
if err != nil {
return nil, err
diff --git a/internal/postgres/package_test.go b/internal/postgres/package_test.go
index 817a802..88996ca 100644
--- a/internal/postgres/package_test.go
+++ b/internal/postgres/package_test.go
@@ -45,8 +45,8 @@
checkPackage := func(got *internal.LegacyVersionedPackage, pkgPath, modulePath, version string) {
t.Helper()
want := &internal.LegacyVersionedPackage{
- ModuleInfo: *sample.ModuleInfo(modulePath, version),
- LegacyPackage: *sample.LegacyPackage(modulePath, suffix(pkgPath, modulePath)),
+ LegacyModuleInfo: *sample.LegacyModuleInfo(modulePath, version),
+ LegacyPackage: *sample.LegacyPackage(modulePath, suffix(pkgPath, modulePath)),
}
want.Imports = nil
opts := cmp.Options{
diff --git a/internal/postgres/path_test.go b/internal/postgres/path_test.go
index 485ba6d..c7a1941 100644
--- a/internal/postgres/path_test.go
+++ b/internal/postgres/path_test.go
@@ -44,7 +44,7 @@
pkgName := path.Base(testModule.packageSuffix)
pkgPath := path.Join(testModule.module, testModule.packageSuffix)
m := &internal.Module{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: testModule.module,
Version: testModule.version,
VersionType: vtype,
diff --git a/internal/proxydatasource/datasource.go b/internal/proxydatasource/datasource.go
index 3e8d40e..d863d9c 100644
--- a/internal/proxydatasource/datasource.go
+++ b/internal/proxydatasource/datasource.go
@@ -83,9 +83,9 @@
return nil, err
}
return &internal.LegacyDirectory{
- Path: dirPath,
- ModuleInfo: v.ModuleInfo,
- Packages: v.LegacyPackages,
+ Path: dirPath,
+ LegacyModuleInfo: v.LegacyModuleInfo,
+ Packages: v.LegacyPackages,
}, nil
}
@@ -96,7 +96,7 @@
return nil, err
}
return &internal.VersionedDirectory{
- ModuleInfo: m.ModuleInfo,
+ LegacyModuleInfo: m.LegacyModuleInfo,
DirectoryNew: internal.DirectoryNew{
Path: dirPath,
V1Path: internal.V1Path(modulePath, strings.TrimPrefix(dirPath, modulePath+"/")),
@@ -193,7 +193,7 @@
// GetPseudoVersionsForModule returns versions from the the proxy /list
// endpoint, if they are pseudoversions. Otherwise, it returns an empty slice.
-func (ds *DataSource) GetPseudoVersionsForModule(ctx context.Context, modulePath string) (_ []*internal.ModuleInfo, err error) {
+func (ds *DataSource) GetPseudoVersionsForModule(ctx context.Context, modulePath string) (_ []*internal.LegacyModuleInfo, err error) {
defer derrors.Wrap(&err, "GetPseudoVersionsForModule(%q)", modulePath)
return ds.listModuleVersions(ctx, modulePath, true)
}
@@ -201,14 +201,14 @@
// GetPseudoVersionsForPackageSeries finds the longest module path containing
// pkgPath, and returns its versions from the proxy /list endpoint, if they are
// pseudoversions. Otherwise, it returns an empty slice.
-func (ds *DataSource) GetPseudoVersionsForPackageSeries(ctx context.Context, pkgPath string) (_ []*internal.ModuleInfo, err error) {
+func (ds *DataSource) GetPseudoVersionsForPackageSeries(ctx context.Context, pkgPath string) (_ []*internal.LegacyModuleInfo, err error) {
defer derrors.Wrap(&err, "GetPseudoVersionsForPackageSeries(%q)", pkgPath)
return ds.listPackageVersions(ctx, pkgPath, true)
}
// GetTaggedVersionsForModule returns versions from the the proxy /list
// endpoint, if they are tagged versions. Otherwise, it returns an empty slice.
-func (ds *DataSource) GetTaggedVersionsForModule(ctx context.Context, modulePath string) (_ []*internal.ModuleInfo, err error) {
+func (ds *DataSource) GetTaggedVersionsForModule(ctx context.Context, modulePath string) (_ []*internal.LegacyModuleInfo, err error) {
defer derrors.Wrap(&err, "GetTaggedVersionsForModule(%q)", modulePath)
return ds.listModuleVersions(ctx, modulePath, false)
}
@@ -216,20 +216,20 @@
// GetTaggedVersionsForPackageSeries finds the longest module path containing
// pkgPath, and returns its versions from the proxy /list endpoint, if they are
// tagged versions. Otherwise, it returns an empty slice.
-func (ds *DataSource) GetTaggedVersionsForPackageSeries(ctx context.Context, pkgPath string) (_ []*internal.ModuleInfo, err error) {
+func (ds *DataSource) GetTaggedVersionsForPackageSeries(ctx context.Context, pkgPath string) (_ []*internal.LegacyModuleInfo, err error) {
defer derrors.Wrap(&err, "GetTaggedVersionsForPackageSeries(%q)", pkgPath)
return ds.listPackageVersions(ctx, pkgPath, false)
}
-// GetModuleInfo returns the ModuleInfo as fetched from the proxy for module
+// GetModuleInfo returns the LegacyModuleInfo as fetched from the proxy for module
// version specified by modulePath and version.
-func (ds *DataSource) GetModuleInfo(ctx context.Context, modulePath, version string) (_ *internal.ModuleInfo, err error) {
+func (ds *DataSource) GetModuleInfo(ctx context.Context, modulePath, version string) (_ *internal.LegacyModuleInfo, err error) {
defer derrors.Wrap(&err, "GetModuleInfo(%q, %q)", modulePath, version)
m, err := ds.getModule(ctx, modulePath, version)
if err != nil {
return nil, err
}
- return &m.ModuleInfo, nil
+ return &m.LegacyModuleInfo, nil
}
// Search is unimplemented.
@@ -312,7 +312,7 @@
// calls the proxy /list endpoint to list its versions. If pseudo is true, it
// filters to pseudo versions. If pseudo is false, it filters to tagged
// versions.
-func (ds *DataSource) listPackageVersions(ctx context.Context, pkgPath string, pseudo bool) (_ []*internal.ModuleInfo, err error) {
+func (ds *DataSource) listPackageVersions(ctx context.Context, pkgPath string, pseudo bool) (_ []*internal.LegacyModuleInfo, err error) {
defer derrors.Wrap(&err, "listPackageVersions(%q, %t)", pkgPath, pseudo)
ds.mu.RLock()
mods := ds.packagePathToModules[pkgPath]
@@ -334,13 +334,13 @@
// calls the proxy /list endpoint to list its versions. If pseudo is true, it
// filters to pseudo versions. If pseudo is false, it filters to tagged
// versions.
-func (ds *DataSource) listModuleVersions(ctx context.Context, modulePath string, pseudo bool) (_ []*internal.ModuleInfo, err error) {
+func (ds *DataSource) listModuleVersions(ctx context.Context, modulePath string, pseudo bool) (_ []*internal.LegacyModuleInfo, err error) {
defer derrors.Wrap(&err, "listModuleVersions(%q, %t)", modulePath, pseudo)
versions, err := ds.proxyClient.ListVersions(ctx, modulePath)
if err != nil {
return nil, err
}
- var vis []*internal.ModuleInfo
+ var vis []*internal.LegacyModuleInfo
ds.mu.RLock()
defer ds.mu.RUnlock()
for _, vers := range versions {
@@ -351,13 +351,13 @@
continue
}
if v, ok := ds.versionCache[versionKey{modulePath, vers}]; ok {
- vis = append(vis, &v.module.ModuleInfo)
+ vis = append(vis, &v.module.LegacyModuleInfo)
} else {
- // In this case we can't produce s ModuleInfo without fully processing
+ // In this case we can't produce s LegacyModuleInfo without fully processing
// the module zip, so we instead append a stub. We could further query
// for this version's /info endpoint to get commit time, but that is
// deferred as a potential future enhancement.
- vis = append(vis, &internal.ModuleInfo{
+ vis = append(vis, &internal.LegacyModuleInfo{
ModulePath: modulePath,
Version: vers,
})
@@ -410,8 +410,8 @@
for _, p := range m.LegacyPackages {
if p.Path == pkgPath {
return &internal.LegacyVersionedPackage{
- LegacyPackage: *p,
- ModuleInfo: m.ModuleInfo,
+ LegacyPackage: *p,
+ LegacyModuleInfo: m.LegacyModuleInfo,
}, nil
}
}
diff --git a/internal/proxydatasource/datasource_test.go b/internal/proxydatasource/datasource_test.go
index f4f5c1a..822ebd4 100644
--- a/internal/proxydatasource/datasource_test.go
+++ b/internal/proxydatasource/datasource_test.go
@@ -60,7 +60,7 @@
GOOS: "linux",
GOARCH: "amd64",
}
- wantModuleInfo = internal.ModuleInfo{
+ wantModuleInfo = internal.LegacyModuleInfo{
ModulePath: "foo.com/bar",
Version: "v1.2.0",
CommitTime: time.Date(2019, 1, 30, 0, 0, 0, 0, time.UTC),
@@ -69,8 +69,8 @@
HasGoMod: true,
}
wantVersionedPackage = &internal.LegacyVersionedPackage{
- ModuleInfo: wantModuleInfo,
- LegacyPackage: wantPackage,
+ LegacyModuleInfo: wantModuleInfo,
+ LegacyPackage: wantPackage,
}
cmpOpts = append([]cmp.Option{
cmpopts.IgnoreFields(internal.LegacyPackage{}, "DocumentationHTML"),
@@ -82,9 +82,9 @@
ctx, ds, teardown := setup(t)
defer teardown()
want := &internal.LegacyDirectory{
- Path: "foo.com/bar",
- ModuleInfo: wantModuleInfo,
- Packages: []*internal.LegacyPackage{&wantPackage},
+ Path: "foo.com/bar",
+ LegacyModuleInfo: wantModuleInfo,
+ Packages: []*internal.LegacyPackage{&wantPackage},
}
got, err := ds.GetDirectory(ctx, "foo.com/bar", internal.UnknownModulePath, "v1.2.0", internal.AllFields)
if err != nil {
@@ -192,8 +192,8 @@
}
v110 := wantModuleInfo
v110.Version = "v1.1.0"
- want := []*internal.ModuleInfo{&wantModuleInfo, &v110}
- ignore := cmpopts.IgnoreFields(internal.ModuleInfo{}, "CommitTime", "VersionType", "IsRedistributable", "HasGoMod")
+ want := []*internal.LegacyModuleInfo{&wantModuleInfo, &v110}
+ ignore := cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "CommitTime", "VersionType", "IsRedistributable", "HasGoMod")
if diff := cmp.Diff(want, got, ignore); diff != "" {
t.Errorf("GetTaggedVersionsForPackageSeries diff (-want +got):\n%s", diff)
}
@@ -213,8 +213,8 @@
}
v110 := wantModuleInfo
v110.Version = "v1.1.0"
- want := []*internal.ModuleInfo{&wantModuleInfo, &v110}
- ignore := cmpopts.IgnoreFields(internal.ModuleInfo{}, "CommitTime", "VersionType", "IsRedistributable", "HasGoMod")
+ want := []*internal.LegacyModuleInfo{&wantModuleInfo, &v110}
+ ignore := cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "CommitTime", "VersionType", "IsRedistributable", "HasGoMod")
if diff := cmp.Diff(want, got, ignore); diff != "" {
t.Errorf("GetTaggedVersionsForPackageSeries diff (-want +got):\n%s", diff)
}
diff --git a/internal/source/source.go b/internal/source/source.go
index 7fd5d3b..6d53d64 100644
--- a/internal/source/source.go
+++ b/internal/source/source.go
@@ -232,14 +232,14 @@
return resp, nil
}
-// ModuleInfo determines the repository corresponding to the module path. It
+// LegacyModuleInfo determines the repository corresponding to the module path. It
// returns a URL to that repo, as well as the directory of the module relative
// to the repo root.
//
-// ModuleInfo may fetch from arbitrary URLs, so it can be slow.
+// LegacyModuleInfo may fetch from arbitrary URLs, so it can be slow.
func ModuleInfo(ctx context.Context, client *Client, modulePath, version string) (info *Info, err error) {
- defer derrors.Wrap(&err, "source.ModuleInfo(ctx, %q, %q)", modulePath, version)
- ctx, span := trace.StartSpan(ctx, "source.ModuleInfo")
+ defer derrors.Wrap(&err, "source.LegacyModuleInfo(ctx, %q, %q)", modulePath, version)
+ ctx, span := trace.StartSpan(ctx, "source.LegacyModuleInfo")
defer span.End()
if modulePath == stdlib.ModulePath {
diff --git a/internal/testing/sample/sample.go b/internal/testing/sample/sample.go
index c63df1a..e3d5bc1 100644
--- a/internal/testing/sample/sample.go
+++ b/internal/testing/sample/sample.go
@@ -105,7 +105,7 @@
}
}
-func ModuleInfo(modulePath, versionString string) *internal.ModuleInfo {
+func LegacyModuleInfo(modulePath, versionString string) *internal.LegacyModuleInfo {
vtype, err := version.ParseType(versionString)
if err != nil {
panic(err)
@@ -117,8 +117,8 @@
// We shouldn't need this, but some code (notably frontend/directory_test.go) creates
// ModuleInfos with "latest" for version, which should not be valid.
-func ModuleInfoReleaseType(modulePath, versionString string) *internal.ModuleInfo {
- return &internal.ModuleInfo{
+func ModuleInfoReleaseType(modulePath, versionString string) *internal.LegacyModuleInfo {
+ return &internal.LegacyModuleInfo{
ModulePath: modulePath,
Version: versionString,
LegacyReadmeFilePath: ReadmeFilePath,
@@ -141,11 +141,11 @@
// Module creates a Module with the given path and version.
// The list of suffixes is used to create LegacyPackages within the module.
func Module(modulePath, version string, suffixes ...string) *internal.Module {
- mi := ModuleInfo(modulePath, version)
+ mi := LegacyModuleInfo(modulePath, version)
m := &internal.Module{
- ModuleInfo: *mi,
- LegacyPackages: nil,
- Licenses: Licenses,
+ LegacyModuleInfo: *mi,
+ LegacyPackages: nil,
+ Licenses: Licenses,
Directories: []*internal.DirectoryNew{
DirectoryNewForModuleRoot(mi, LicenseMetadata),
},
@@ -191,7 +191,7 @@
}
}
-func DirectoryNewForModuleRoot(m *internal.ModuleInfo, licenses []*licenses.Metadata) *internal.DirectoryNew {
+func DirectoryNewForModuleRoot(m *internal.LegacyModuleInfo, licenses []*licenses.Metadata) *internal.DirectoryNew {
d := &internal.DirectoryNew{
Path: m.ModulePath,
IsRedistributable: m.IsRedistributable,
diff --git a/internal/worker/fetch_test.go b/internal/worker/fetch_test.go
index 1f5a89a..1802767 100644
--- a/internal/worker/fetch_test.go
+++ b/internal/worker/fetch_test.go
@@ -629,7 +629,7 @@
t.Fatalf("FetchAndUpdateState(%q, %q, %v, %v, %v): %v", modulePath, version, proxyClient, sourceClient, testDB, err)
}
want := &internal.LegacyVersionedPackage{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: modulePath,
Version: version,
CommitTime: time.Date(2019, 1, 30, 0, 0, 0, 0, time.UTC),
@@ -768,7 +768,7 @@
defer teardownProxy()
myModuleV100 := &internal.LegacyVersionedPackage{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "github.com/my/module",
Version: "v1.0.0",
CommitTime: testProxyCommitTime,
@@ -822,7 +822,7 @@
version: "v1.0.0",
pkg: "nonredistributable.mod/module/bar/baz",
want: &internal.LegacyVersionedPackage{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "nonredistributable.mod/module",
Version: "v1.0.0",
CommitTime: testProxyCommitTime,
@@ -854,7 +854,7 @@
version: "v1.0.0",
pkg: "nonredistributable.mod/module/foo",
want: &internal.LegacyVersionedPackage{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "nonredistributable.mod/module",
Version: "v1.0.0",
CommitTime: testProxyCommitTime,
@@ -884,7 +884,7 @@
version: "v1.12.5",
pkg: "context",
want: &internal.LegacyVersionedPackage{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "std",
Version: "v1.12.5",
CommitTime: stdlib.TestCommitTime,
@@ -917,7 +917,7 @@
version: "v1.12.5",
pkg: "builtin",
want: &internal.LegacyVersionedPackage{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "std",
Version: "v1.12.5",
CommitTime: stdlib.TestCommitTime,
@@ -950,7 +950,7 @@
version: "v1.12.5",
pkg: "encoding/json",
want: &internal.LegacyVersionedPackage{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "std",
Version: "v1.12.5",
CommitTime: stdlib.TestCommitTime,
@@ -996,7 +996,7 @@
version: "v1.0.0",
pkg: "build.constraints/module/cpu",
want: &internal.LegacyVersionedPackage{
- ModuleInfo: internal.ModuleInfo{
+ LegacyModuleInfo: internal.LegacyModuleInfo{
ModulePath: "build.constraints/module",
Version: "v1.0.0",
CommitTime: testProxyCommitTime,
@@ -1040,7 +1040,7 @@
if err != nil {
t.Fatal(err)
}
- if diff := cmp.Diff(test.want.ModuleInfo, *gotModuleInfo, cmp.AllowUnexported(source.Info{})); diff != "" {
+ if diff := cmp.Diff(test.want.LegacyModuleInfo, *gotModuleInfo, cmp.AllowUnexported(source.Info{})); diff != "" {
t.Fatalf("testDB.GetModuleInfo(ctx, %q, %q) mismatch (-want +got):\n%s", test.modulePath, test.version, diff)
}