-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add k8s.io/release/pkg/license package #1874
Conversation
Example run of test script (with licenses cached):
|
Running times without licenses pre cached:
|
pkg/license/license.go
Outdated
// Get the license corresponding to the ID label | ||
license := d.spdx.GetLicense(label) | ||
if license == nil { | ||
return nil, unrecognizedPaths, errors.Wrapf(nil, "ID does not correspond to a valid license: %s", label) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapping a nil error will always result in nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooof nice catch. Thanks!
This commit adds a new `license` package which as if now includes a new license reader that identifies licenses in a source code directory. The source consists of three parts: * The license reader code * The SPDX functions and data structures * A downloader object that gets and caches license data from spdx.org Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
This commit contains the autogenerated fakes to mock the implementations in the license package Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
Tests for the license package. They are split in a couple of unit tests performed in package and the rest, in their own package (license_test) Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: puerco, saschagrunert The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR adds a new
license
package which, as of now, includes a new license readerthat scans a directory and identifies license files located in it.
The main source consists of three parts:
* The license reader code
* The SPDX functions and data structures
* A downloader object that gets and caches license data from spdx.org
An example test program (see bellow for sample output):
After trying several solutions and even writing my own, I settled on using google's license classifier which turned out to be the most practical to use as well as the fastest and most accurate.
Which issue(s) this PR fixes:
Part of #1837
Special notes for your reviewer:
Tests and mock implementations are included. One test file contains unit tests that run in -package while the other has all unit and integration tests that run in its own package (license_test)
Does this PR introduce a user-facing change?