mirror of https://github.com/knative/docs.git
[master] Auto-update dependencies (#2460)
Produced via: `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh` /assign dprotaso grantr samodell /cc dprotaso grantr samodell
This commit is contained in:
parent
d48f7b0bd7
commit
891a4d3a16
|
@ -501,14 +501,14 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:a0273906fa66a9119bf8a8b8b373084190cfb8a44a176d2d02b48cf46302ce40"
|
||||
digest = "1:472814638003e0a895a794f2647e4f5b1c888f211d803535c1da5e276257033a"
|
||||
name = "knative.dev/test-infra"
|
||||
packages = [
|
||||
"scripts",
|
||||
"tools/dep-collector",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "371b0a511a3b2d8e6e24f3bd880e32a48b426f5b"
|
||||
revision = "2b7ecf0da96165d1523bc8b24880b92a2cb15c5f"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
|
|
|
@ -302,6 +302,8 @@ function main() {
|
|||
kubectl version --client
|
||||
echo ">> go version"
|
||||
go version
|
||||
echo ">> go env"
|
||||
go env
|
||||
echo ">> python3 version"
|
||||
python3 --version
|
||||
echo ">> git version"
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# dep-collector
|
||||
|
||||
> Deprecation notice: the CI/CD flow has switched the license tool to
|
||||
> [go-licenses](https://github.com/google/go-licenses), and deprecated
|
||||
> `dep-collector`. We need to keep it for now as the old release branches are
|
||||
> still using it. It can be safely deleted after we only support branches >=
|
||||
> release-0.15.
|
||||
|
||||
`dep-collector` is a tool for gathering up a collection of licenses for Go
|
||||
dependencies that have been pulled into the idiomatic `vendor/` directory. The
|
||||
resulting file from running `dep-collector` is intended for inclusion in
|
||||
|
|
|
@ -27,6 +27,48 @@ import (
|
|||
"github.com/google/licenseclassifier"
|
||||
)
|
||||
|
||||
// Type identifies a class of software license.
|
||||
type Type string
|
||||
|
||||
// License types
|
||||
const (
|
||||
// Unknown license type.
|
||||
Unknown = Type("")
|
||||
// Restricted licenses require mandatory source distribution if we ship a
|
||||
// product that includes third-party code protected by such a license.
|
||||
Restricted = Type("restricted")
|
||||
// Reciprocal licenses allow usage of software made available under such
|
||||
// licenses freely in *unmodified* form. If the third-party source code is
|
||||
// modified in any way these modifications to the original third-party
|
||||
// source code must be made available.
|
||||
Reciprocal = Type("reciprocal")
|
||||
// Notice licenses contain few restrictions, allowing original or modified
|
||||
// third-party software to be shipped in any product without endangering or
|
||||
// encumbering our source code. All of the licenses in this category do,
|
||||
// however, have an "original Copyright notice" or "advertising clause",
|
||||
// wherein any external distributions must include the notice or clause
|
||||
// specified in the license.
|
||||
Notice = Type("notice")
|
||||
// Permissive licenses are even more lenient than a 'notice' license.
|
||||
// Not even a copyright notice is required for license compliance.
|
||||
Permissive = Type("permissive")
|
||||
// Unencumbered covers licenses that basically declare that the code is "free for any use".
|
||||
Unencumbered = Type("unencumbered")
|
||||
// Forbidden licenses are forbidden to be used.
|
||||
Forbidden = Type("FORBIDDEN")
|
||||
)
|
||||
|
||||
func (t Type) String() string {
|
||||
switch t {
|
||||
case Unknown:
|
||||
// licenseclassifier uses an empty string to indicate an unknown license
|
||||
// type, which is unclear to users when printed as a string.
|
||||
return "unknown"
|
||||
default:
|
||||
return string(t)
|
||||
}
|
||||
}
|
||||
|
||||
var LicenseNames = []string{
|
||||
"LICENCE",
|
||||
"LICENSE",
|
||||
|
@ -52,32 +94,32 @@ func (lf *LicenseFile) Body() (string, error) {
|
|||
return string(body), nil
|
||||
}
|
||||
|
||||
func (lt *LicenseFile) Classify(classifier *licenseclassifier.License) (string, error) {
|
||||
body, err := lt.Body()
|
||||
func (lf *LicenseFile) Classify(classifier *licenseclassifier.License) (string, error) {
|
||||
body, err := lf.Body()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
m := classifier.NearestMatch(body)
|
||||
if m == nil {
|
||||
return "", fmt.Errorf("unable to classify license: %v", lt.EnclosingImportPath)
|
||||
return "", fmt.Errorf("unable to classify license: %v", lf.EnclosingImportPath)
|
||||
}
|
||||
return m.Name, nil
|
||||
}
|
||||
|
||||
func (lt *LicenseFile) Check(classifier *licenseclassifier.License) error {
|
||||
body, err := lt.Body()
|
||||
func (lf *LicenseFile) Check(classifier *licenseclassifier.License) error {
|
||||
body, err := lf.Body()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ms := classifier.MultipleMatch(body, false)
|
||||
for _, m := range ms {
|
||||
return fmt.Errorf("found matching forbidden license in %q: %v", lt.EnclosingImportPath, m.Name)
|
||||
return fmt.Errorf("found matching forbidden license in %q: %v", lf.EnclosingImportPath, m.Name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (lt *LicenseFile) Entry() (string, error) {
|
||||
body, err := lt.Body()
|
||||
func (lf *LicenseFile) Entry() (string, error) {
|
||||
body, err := lf.Body()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -86,23 +128,23 @@ func (lt *LicenseFile) Entry() (string, error) {
|
|||
Import: %s
|
||||
|
||||
%s
|
||||
`, lt.EnclosingImportPath, body), nil
|
||||
`, lf.EnclosingImportPath, body), nil
|
||||
}
|
||||
|
||||
func (lt *LicenseFile) CSVRow(classifier *licenseclassifier.License) (string, error) {
|
||||
classification, err := lt.Classify(classifier)
|
||||
func (lf *LicenseFile) CSVRow(classifier *licenseclassifier.License) (string, error) {
|
||||
classification, err := lf.Classify(classifier)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
parts := strings.Split(lt.EnclosingImportPath, "/vendor/")
|
||||
parts := strings.Split(lf.EnclosingImportPath, "/vendor/")
|
||||
if len(parts) != 2 {
|
||||
return "", fmt.Errorf("wrong number of parts splitting import path on %q : %q", "/vendor/", lt.EnclosingImportPath)
|
||||
return "", fmt.Errorf("wrong number of parts splitting import path on %q : %q", "/vendor/", lf.EnclosingImportPath)
|
||||
}
|
||||
return strings.Join([]string{
|
||||
parts[1],
|
||||
"Static",
|
||||
"", // TODO(mattmoor): Modifications?
|
||||
"https://" + parts[0] + "/blob/master/vendor/" + parts[1] + "/" + filepath.Base(lt.LicensePath),
|
||||
"https://" + parts[0] + "/blob/master/vendor/" + parts[1] + "/" + filepath.Base(lf.LicensePath),
|
||||
classification,
|
||||
}, ","), nil
|
||||
}
|
||||
|
@ -163,8 +205,12 @@ func (lc LicenseCollection) CSV(classifier *licenseclassifier.License) (string,
|
|||
func (lc LicenseCollection) Check(classifier *licenseclassifier.License) error {
|
||||
errors := []string{}
|
||||
for _, entry := range lc {
|
||||
if err := entry.Check(classifier); err != nil {
|
||||
errors = append(errors, err.Error())
|
||||
licenseName, licenseType, err := entry.Identify(entry.LicensePath, classifier)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if licenseType == Forbidden {
|
||||
errors = append(errors, fmt.Sprintf("Forbidden license type %s for library %v\n", licenseName, entry))
|
||||
}
|
||||
}
|
||||
if len(errors) == 0 {
|
||||
|
@ -173,6 +219,24 @@ func (lc LicenseCollection) Check(classifier *licenseclassifier.License) error {
|
|||
return fmt.Errorf("Errors validating licenses:\n%v", strings.Join(errors, "\n"))
|
||||
}
|
||||
|
||||
// Identify returns the name and type of a license, given its file path.
|
||||
// An empty license path results in an empty name and Unknown type.
|
||||
func (lf *LicenseFile) Identify(licensePath string, classifier *licenseclassifier.License) (string, Type, error) {
|
||||
if licensePath == "" {
|
||||
return "", Unknown, nil
|
||||
}
|
||||
content, err := ioutil.ReadFile(licensePath)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
matches := classifier.MultipleMatch(string(content), true)
|
||||
if len(matches) == 0 {
|
||||
return "", "", fmt.Errorf("unknown license")
|
||||
}
|
||||
licenseName := matches[0].Name
|
||||
return licenseName, Type(licenseclassifier.LicenseType(licenseName)), nil
|
||||
}
|
||||
|
||||
// CollectLicenses collects a list of licenses for the given imports.
|
||||
func CollectLicenses(importInfos []ImportInfo) (LicenseCollection, error) {
|
||||
// for each of the import paths, search for a license file.
|
||||
|
|
|
@ -50,7 +50,7 @@ func main() {
|
|||
}
|
||||
|
||||
if *check {
|
||||
classifier, err := licenseclassifier.NewWithForbiddenLicenses(MatchThreshold)
|
||||
classifier, err := licenseclassifier.New(MatchThreshold)
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating license classifier: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue