[master] Auto-update dependencies (#272)

Produced via:
  `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh`
/assign n3wscott vagababov
/cc n3wscott vagababov
This commit is contained in:
Matt Moore 2020-05-13 10:13:58 -07:00 committed by GitHub
parent 9829da342e
commit 85661149a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 203 additions and 160 deletions

4
go.mod
View File

@ -16,8 +16,8 @@ require (
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/code-generator v0.18.0
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
knative.dev/pkg v0.0.0-20200511223446-de5c590700ff
knative.dev/test-infra v0.0.0-20200512045203-371b0a511a3b
knative.dev/pkg v0.0.0-20200512191130-b10849aacf82
knative.dev/test-infra v0.0.0-20200513011557-d03429a76034
)
replace (

8
go.sum
View File

@ -1371,15 +1371,15 @@ knative.dev/pkg v0.0.0-20191111150521-6d806b998379/go.mod h1:pgODObA1dTyhNoFxPZT
knative.dev/pkg v0.0.0-20200428194351-90fc61bae7f7/go.mod h1:o+e8OVEJKIuvXPsGVPIautjXgs05xbos7G+QMRjuUps=
knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2 h1:Qu2NlOHb9p3g+CSL/ok9+FySowN60URFEKRSXfWtDv4=
knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2/go.mod h1:Q6sL35DdGs8hIQZKdaCXJGgY8f90BmNBKSb8z6d/BTM=
knative.dev/pkg v0.0.0-20200511223446-de5c590700ff h1:r1tjC1OEOxyonjQmuZaCJpK7bHBbCSXq/gBXLE0i91M=
knative.dev/pkg v0.0.0-20200511223446-de5c590700ff/go.mod h1:gv+6TBl/yLc/x2dpVfmjF+MWLbxWRm9ie5dJRASsPmw=
knative.dev/pkg v0.0.0-20200512191130-b10849aacf82 h1:fNi8SJwQ5ADR0vj5EEpAcgdqlMKG1Ukym6BROixBLcc=
knative.dev/pkg v0.0.0-20200512191130-b10849aacf82/go.mod h1:gv+6TBl/yLc/x2dpVfmjF+MWLbxWRm9ie5dJRASsPmw=
knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55 h1:Ajn44+eHHjPQL/BQicj8LMy8VTD2ypMCfHJuZVGEtew=
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU=
knative.dev/test-infra v0.0.0-20200509000045-c7114387eed5 h1:4lQU2AMChE3Hb2WgHDFfhRbYlITCMUgQ2Y6eeIIEgxM=
knative.dev/test-infra v0.0.0-20200509000045-c7114387eed5/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
knative.dev/test-infra v0.0.0-20200512045203-371b0a511a3b h1:DoGeiLb+XUrnPZPqph8hrzI+G1DyCxortjD+g2Svsr0=
knative.dev/test-infra v0.0.0-20200512045203-371b0a511a3b/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
knative.dev/test-infra v0.0.0-20200513011557-d03429a76034 h1:JxqONCZVS7or+Fv3ebVQoipuIBH7Ig3Qbx170hgIF+A=
knative.dev/test-infra v0.0.0-20200513011557-d03429a76034/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=

View File

@ -173,17 +173,11 @@ func MustParseClientGenTags(lines []string) Tags {
Tags: util.MustParseClientGenTags(lines),
}
values := types.ExtractCommentTags("+", lines)
values := ExtractCommentTags("+", lines)
_, ret.GenerateDuck = values["genduck"]
_, genRec := values["genreconciler"]
_, genRecClass := values["genreconciler:class"]
// Generate Reconciler code if genreconciler OR genreconciler:class exist.
if genRec || genRecClass {
ret.GenerateReconciler = true
}
_, ret.GenerateReconciler = values["genreconciler"]
return ret
}
@ -202,6 +196,14 @@ func extractReconcilerClassTag(tags map[string]map[string]string) (string, bool)
return classname, has
}
func isKRShaped(tags map[string]map[string]string) bool {
vals, has := tags["genreconciler"]
if !has {
return false
}
return vals["krshapedlogic"] == "true"
}
func isNonNamespaced(tags map[string]map[string]string) bool {
vals, has := tags["genclient"]
if !has {
@ -211,15 +213,6 @@ func isNonNamespaced(tags map[string]map[string]string) bool {
return has
}
func isKRShaped(tags map[string]map[string]string) bool {
vals, has := tags["genclient"]
if !has {
return false
}
shaped, _ := vals["krshapedlogic"]
return shaped == "true"
}
func vendorless(p string) string {
if pos := strings.LastIndex(p, "/vendor/"); pos != -1 {
return p[pos+len("/vendor/"):]
@ -234,118 +227,108 @@ func typedInformerPackage(groupPkgName string, gv clientgentypes.GroupVersion, e
func versionClientsPackages(basePackage string, boilerplate []byte, customArgs *informergenargs.CustomArgs) []generator.Package {
packagePath := filepath.Join(basePackage, "client")
vers := make([]generator.Package, 0, 2)
// Impl
vers = append(vers, &generator.DefaultPackage{
PackageName: "client",
PackagePath: packagePath,
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
// Impl
generators = append(generators, &clientGenerator{
DefaultGen: generator.DefaultGen{
OptionalName: "client",
},
outputPackage: packagePath,
imports: generator.NewImportTracker(),
clientSetPackage: customArgs.VersionedClientSetPackage,
})
return generators
vers := []generator.Package{
// Impl
&generator.DefaultPackage{
PackageName: "client",
PackagePath: packagePath,
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
// Impl
generators = append(generators, &clientGenerator{
DefaultGen: generator.DefaultGen{
OptionalName: "client",
},
outputPackage: packagePath,
imports: generator.NewImportTracker(),
clientSetPackage: customArgs.VersionedClientSetPackage,
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
// Fake
&generator.DefaultPackage{
PackageName: "fake",
PackagePath: filepath.Join(packagePath, "fake"),
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
// Impl
generators = append(generators, &fakeClientGenerator{
DefaultGen: generator.DefaultGen{
OptionalName: "fake",
},
outputPackage: filepath.Join(packagePath, "fake"),
imports: generator.NewImportTracker(),
fakeClientPkg: filepath.Join(customArgs.VersionedClientSetPackage, "fake"),
clientInjectionPkg: packagePath,
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
},
})
// Fake
vers = append(vers, &generator.DefaultPackage{
PackageName: "fake",
PackagePath: filepath.Join(packagePath, "fake"),
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
// Impl
generators = append(generators, &fakeClientGenerator{
DefaultGen: generator.DefaultGen{
OptionalName: "fake",
},
outputPackage: filepath.Join(packagePath, "fake"),
imports: generator.NewImportTracker(),
fakeClientPkg: filepath.Join(customArgs.VersionedClientSetPackage, "fake"),
clientInjectionPkg: packagePath,
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
})
}
return vers
}
func versionFactoryPackages(basePackage string, boilerplate []byte, customArgs *informergenargs.CustomArgs) []generator.Package {
packagePath := filepath.Join(basePackage, "informers", "factory")
vers := make([]generator.Package, 0, 2)
// Impl
vers = append(vers, &generator.DefaultPackage{
PackageName: "factory",
PackagePath: packagePath,
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
// Impl
generators = append(generators, &factoryGenerator{
DefaultGen: generator.DefaultGen{
OptionalName: "factory",
},
outputPackage: packagePath,
cachingClientSetPackage: filepath.Join(basePackage, "client"),
sharedInformerFactoryPackage: customArgs.ExternalVersionsInformersPackage,
imports: generator.NewImportTracker(),
})
return generators
vers := []generator.Package{
// Impl
&generator.DefaultPackage{
PackageName: "factory",
PackagePath: packagePath,
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
// Impl
generators = append(generators, &factoryGenerator{
DefaultGen: generator.DefaultGen{
OptionalName: "factory",
},
outputPackage: packagePath,
cachingClientSetPackage: filepath.Join(basePackage, "client"),
sharedInformerFactoryPackage: customArgs.ExternalVersionsInformersPackage,
imports: generator.NewImportTracker(),
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
// Fake
&generator.DefaultPackage{
PackageName: "fake",
PackagePath: filepath.Join(packagePath, "fake"),
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
// Impl
generators = append(generators, &fakeFactoryGenerator{
DefaultGen: generator.DefaultGen{
OptionalName: "fake",
},
outputPackage: filepath.Join(packagePath, "fake"),
factoryInjectionPkg: packagePath,
fakeClientInjectionPkg: filepath.Join(basePackage, "client", "fake"),
sharedInformerFactoryPackage: customArgs.ExternalVersionsInformersPackage,
imports: generator.NewImportTracker(),
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
},
})
// Fake
vers = append(vers, &generator.DefaultPackage{
PackageName: "fake",
PackagePath: filepath.Join(packagePath, "fake"),
HeaderText: boilerplate,
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
// Impl
generators = append(generators, &fakeFactoryGenerator{
DefaultGen: generator.DefaultGen{
OptionalName: "fake",
},
outputPackage: filepath.Join(packagePath, "fake"),
factoryInjectionPkg: packagePath,
fakeClientInjectionPkg: filepath.Join(basePackage, "client", "fake"),
sharedInformerFactoryPackage: customArgs.ExternalVersionsInformersPackage,
imports: generator.NewImportTracker(),
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
tags := MustParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
return tags.NeedsInformerInjection()
},
})
}
return vers
}
@ -353,12 +336,11 @@ func versionInformerPackages(basePackage string, groupPkgName string, gv clientg
factoryPackagePath := filepath.Join(basePackage, "informers", "factory")
packagePath := filepath.Join(basePackage, "informers", groupPkgName, strings.ToLower(gv.Version.NonEmpty()))
vers := make([]generator.Package, 0, len(typesToGenerate))
vers := make([]generator.Package, 0, 2*len(typesToGenerate))
for _, t := range typesToGenerate {
// Fix for golang iterator bug.
t := t
packagePath := packagePath + "/" + strings.ToLower(t.Name.Name)
typedInformerPackage := typedInformerPackage(groupPkgName, gv, customArgs.ExternalVersionsInformersPackage)
@ -381,7 +363,6 @@ func versionInformerPackages(basePackage string, groupPkgName string, gv clientg
typedInformerPackage: typedInformerPackage,
groupInformerFactoryPackage: factoryPackagePath,
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
@ -409,7 +390,6 @@ func versionInformerPackages(basePackage string, groupPkgName string, gv clientg
informerInjectionPkg: packagePath,
fakeFactoryInjectionPkg: filepath.Join(factoryPackagePath, "fake"),
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
@ -423,13 +403,13 @@ func versionInformerPackages(basePackage string, groupPkgName string, gv clientg
func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentypes.GroupVersion, groupGoName string, boilerplate []byte, typesToGenerate []*types.Type, customArgs *informergenargs.CustomArgs) []generator.Package {
packagePath := filepath.Join(basePackage, "reconciler", groupPkgName, strings.ToLower(gv.Version.NonEmpty()))
clientPackagePath := filepath.Join(basePackage, "client")
vers := make([]generator.Package, 0, len(typesToGenerate))
vers := make([]generator.Package, 0, 4*len(typesToGenerate))
for _, t := range typesToGenerate {
// Fix for golang iterator bug.
t := t
extracted := extractCommentTags(t)
reconcilerClass, hasReconcilerClass := extractReconcilerClassTag(extracted)
nonNamespaced := isNonNamespaced(extracted)
@ -437,9 +417,7 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
packagePath := filepath.Join(packagePath, strings.ToLower(t.Name.Name))
clientPackagePath := filepath.Join(basePackage, "client")
informerPackagePath := filepath.Join(basePackage, "informers", groupPkgName, strings.ToLower(gv.Version.NonEmpty()), strings.ToLower(t.Name.Name))
listerPackagePath := filepath.Join(customArgs.ListersPackage, groupPkgName, strings.ToLower(gv.Version.NonEmpty()))
// Controller
@ -463,7 +441,6 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
reconcilerClass: reconcilerClass,
hasReconcilerClass: hasReconcilerClass,
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
@ -491,7 +468,6 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
reconcilerClass: reconcilerClass,
hasReconcilerClass: hasReconcilerClass,
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
@ -524,7 +500,6 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
nonNamespaced: nonNamespaced,
isKRShaped: isKRShaped,
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
@ -549,7 +524,6 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
outputPackage: filepath.Join(packagePath, "stub"),
imports: generator.NewImportTracker(),
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
@ -564,12 +538,11 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp
func versionDuckPackages(basePackage string, groupPkgName string, gv clientgentypes.GroupVersion, groupGoName string, boilerplate []byte, typesToGenerate []*types.Type, customArgs *informergenargs.CustomArgs) []generator.Package {
packagePath := filepath.Join(basePackage, "ducks", groupPkgName, strings.ToLower(gv.Version.NonEmpty()))
vers := make([]generator.Package, 0, len(typesToGenerate))
vers := make([]generator.Package, 0, 2*len(typesToGenerate))
for _, t := range typesToGenerate {
// Fix for golang iterator bug.
t := t
packagePath := filepath.Join(packagePath, strings.ToLower(t.Name.Name))
// Impl
@ -589,7 +562,6 @@ func versionDuckPackages(basePackage string, groupPkgName string, gv clientgenty
typeToGenerate: t,
imports: generator.NewImportTracker(),
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {
@ -616,7 +588,6 @@ func versionDuckPackages(basePackage string, groupPkgName string, gv clientgenty
groupGoName: groupGoName,
duckInjectionPkg: packagePath,
})
return generators
},
FilterFunc: func(c *generator.Context, t *types.Type) bool {

View File

@ -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"

View File

@ -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

View File

@ -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.

View 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)
}

4
vendor/modules.txt vendored
View File

@ -656,7 +656,7 @@ k8s.io/kube-openapi/pkg/util/sets
k8s.io/utils/buffer
k8s.io/utils/integer
k8s.io/utils/trace
# knative.dev/pkg v0.0.0-20200511223446-de5c590700ff
# knative.dev/pkg v0.0.0-20200512191130-b10849aacf82
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
knative.dev/pkg/apis/duck/v1
@ -676,7 +676,7 @@ knative.dev/pkg/metrics
knative.dev/pkg/metrics/metricskey
knative.dev/pkg/reconciler
knative.dev/pkg/tracker
# knative.dev/test-infra v0.0.0-20200512045203-371b0a511a3b
# knative.dev/test-infra v0.0.0-20200513011557-d03429a76034
knative.dev/test-infra/scripts
knative.dev/test-infra/tools/dep-collector
# sigs.k8s.io/yaml v1.1.0