Skip to content

x/pkgsite: add postgres.GetLicenses function to return licenses for a given path #40027

@julieqiu

Description

@julieqiu

As part of the new data model migration (#39629), we will have a single function get licenses for a given path (regardless of whether that path is a package, module, or directory).

This function will replace the existing LegacyGetPackageLicenses and LegacyGetModuleLicenses.

The function signature will be:

GetLicenses(ctx context.Context, fullpath, modulePath, resolvedVersion string)([]*licenses.License, error)

The function will execute the query below:

SELECT
    l.types,
    l.file_path,
    l.contents,
    l.coverage
FROM
    licenses l
INNER JOIN
    paths p
ON
    p.module_id=l.module_id
INNER JOIN
    modules m
ON
    p.module_id=m.id
WHERE
    p.path = $1
    AND m.module_path = $2
    AND m.version = $3;

Only licenses relevant to the path should be returned. A license applies to the path if the license is in the path directory, or any of its parent directories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.SuggestedIssues that may be good for new contributors looking for work to do.help wantedpkgsite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions