Skip to content
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

chore: update licenses database #4149

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions tools/licensescan/licensedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ import (
"io/fs"
"os"
"path/filepath"
"sort"
"strings"
"testing"

"sigs.k8s.io/yaml"
)

// Test that the license didn't change for the same module
func TestLicensesForConsistency(t *testing.T) {
files := make(map[string]*moduleInfo)
type moduleVersion struct {
ModuleInfo *moduleInfo
Version string
}

modules := make(map[string][]*moduleVersion)

if err := filepath.Walk("modules", func(p string, info fs.FileInfo, err error) error {
if err != nil {
Expand All @@ -46,30 +53,35 @@ func TestLicensesForConsistency(t *testing.T) {
return fmt.Errorf("error parsing %q: %w", p, err)
}

files[p] = m
modulePath := filepath.Dir(p)
modulePath = strings.TrimPrefix(modulePath, "modules/")
version := filepath.Base(p)
version = strings.TrimSuffix(version, ".yaml")
modules[modulePath] = append(modules[modulePath], &moduleVersion{
ModuleInfo: m,
Version: version,
})
return nil
}); err != nil {
t.Fatalf("error during walk: %v", err)
}

for f1, m1 := range files {
dir := filepath.Dir(f1)
for f2, m2 := range files {
// Only compare pairs once
if f1 >= f2 {
continue
}

if filepath.Dir(f2) != dir {
continue
}
for module, versions := range modules {
sort.Slice(versions, func(i, j int) bool {
return versions[i].Version < versions[j].Version
})
for i := 0; i < len(versions)-1; i++ {
v1 := versions[i]
v2 := versions[i+1]

if m1.License != m2.License {
switch f1 {
case "modules/github.com/klauspost/compress/v1.11.2.yaml":
if v1.ModuleInfo.License != v2.ModuleInfo.License {
switch module + "@" + v1.Version {
case "github.com/klauspost/compress@v1.11.2":
// license changed after v1.11.2
case "sigs.k8s.io/[email protected]":
// license changed after v1.3.0
default:
t.Errorf("license mismatch: %v=%v, %v=%v", f1, m1.License, f2, m2.License)
t.Errorf("license mismatch: %v %v=%v, %v=%v", module, v1.Version, v1.ModuleInfo.License, v2.Version, v2.ModuleInfo.License)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/cpuguy83/go-md2man/[email protected]
license: MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/docker/[email protected]+incompatible
license: Apache-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/docker/[email protected]+incompatible
license: Apache-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/gammazero/[email protected]
license: MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/gammazero/[email protected]
license: MIT
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# https://pkg.go.dev/github.com/google/[email protected]
license: BSD-3-Clause
license: BSD-3-Clause
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/google/[email protected]
license: Apache-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/hashicorp/[email protected]
license: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/hashicorp/[email protected]
license: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/hashicorp/[email protected]
license: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/hashicorp/[email protected]
license: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/klauspost/[email protected]
license: Apache-2.0, BSD-3-Clause, MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/moby/[email protected]
license: Apache-2.0
2 changes: 2 additions & 0 deletions tools/licensescan/modules/github.com/moby/term/v0.5.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/moby/[email protected]
license: Apache-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/sirupsen/[email protected]
license: MIT
2 changes: 2 additions & 0 deletions tools/licensescan/modules/github.com/spf13/cobra/v1.8.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/spf13/[email protected]
license: Apache-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/github.com/vbatts/[email protected]
license: BSD-3-Clause
2 changes: 2 additions & 0 deletions tools/licensescan/modules/golang.org/x/crypto/v0.21.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/golang.org/x/[email protected]
license: BSD-3-Clause
2 changes: 2 additions & 0 deletions tools/licensescan/modules/golang.org/x/mod/v0.17.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/golang.org/x/[email protected]
license: BSD-3-Clause
2 changes: 2 additions & 0 deletions tools/licensescan/modules/golang.org/x/net/v0.23.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/golang.org/x/[email protected]
license: BSD-3-Clause
2 changes: 2 additions & 0 deletions tools/licensescan/modules/golang.org/x/sync/v0.2.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/golang.org/x/[email protected]
license: BSD-3-Clause
2 changes: 2 additions & 0 deletions tools/licensescan/modules/golang.org/x/sys/v0.18.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/golang.org/x/[email protected]
license: BSD-3-Clause
2 changes: 2 additions & 0 deletions tools/licensescan/modules/golang.org/x/term/v0.18.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/golang.org/x/[email protected]
license: BSD-3-Clause
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/google.golang.org/[email protected]
license: BSD-3-Clause
2 changes: 2 additions & 0 deletions tools/licensescan/modules/istio.io/api/v1.21.2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/istio.io/[email protected]
license: Apache-2.0
2 changes: 2 additions & 0 deletions tools/licensescan/modules/k8s.io/klog/v2/v2.120.1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/k8s.io/klog/[email protected]
license: Apache-2.0
2 changes: 2 additions & 0 deletions tools/licensescan/modules/sigs.k8s.io/yaml/v1.4.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://pkg.go.dev/sigs.k8s.io/[email protected]
license: Apache-2.0, BSD-3-Clause, MIT
Loading