diff --git a/tools/licensescan/licensedb_test.go b/tools/licensescan/licensedb_test.go index 753f23389f..db87b5a68b 100644 --- a/tools/licensescan/licensedb_test.go +++ b/tools/licensescan/licensedb_test.go @@ -19,6 +19,8 @@ import ( "io/fs" "os" "path/filepath" + "sort" + "strings" "testing" "sigs.k8s.io/yaml" @@ -26,7 +28,12 @@ import ( // 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 { @@ -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/yaml@v1.3.0": + // 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) } } diff --git a/tools/licensescan/modules/github.com/cpuguy83/go-md2man/v2/v2.0.3.yaml b/tools/licensescan/modules/github.com/cpuguy83/go-md2man/v2/v2.0.3.yaml new file mode 100644 index 0000000000..62c46b71c7 --- /dev/null +++ b/tools/licensescan/modules/github.com/cpuguy83/go-md2man/v2/v2.0.3.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/cpuguy83/go-md2man/v2@v2.0.3 +license: MIT diff --git a/tools/licensescan/modules/github.com/docker/cli/v24.0.0+incompatible.yaml b/tools/licensescan/modules/github.com/docker/cli/v24.0.0+incompatible.yaml new file mode 100644 index 0000000000..f796b1762f --- /dev/null +++ b/tools/licensescan/modules/github.com/docker/cli/v24.0.0+incompatible.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/docker/cli@v24.0.0+incompatible +license: Apache-2.0 diff --git a/tools/licensescan/modules/github.com/docker/docker/v24.0.9+incompatible.yaml b/tools/licensescan/modules/github.com/docker/docker/v24.0.9+incompatible.yaml new file mode 100644 index 0000000000..120c14403f --- /dev/null +++ b/tools/licensescan/modules/github.com/docker/docker/v24.0.9+incompatible.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/docker/docker@v24.0.9+incompatible +license: Apache-2.0 diff --git a/tools/licensescan/modules/github.com/gammazero/deque/v0.2.1.yaml b/tools/licensescan/modules/github.com/gammazero/deque/v0.2.1.yaml new file mode 100644 index 0000000000..a186e7a44f --- /dev/null +++ b/tools/licensescan/modules/github.com/gammazero/deque/v0.2.1.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/gammazero/deque@v0.2.1 +license: MIT \ No newline at end of file diff --git a/tools/licensescan/modules/github.com/gammazero/workerpool/v1.1.3.yaml b/tools/licensescan/modules/github.com/gammazero/workerpool/v1.1.3.yaml new file mode 100644 index 0000000000..7669ac5b37 --- /dev/null +++ b/tools/licensescan/modules/github.com/gammazero/workerpool/v1.1.3.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/gammazero/workerpool@v1.1.3 +license: MIT \ No newline at end of file diff --git a/tools/licensescan/modules/github.com/google/go-cmp/v0.6.0.yaml b/tools/licensescan/modules/github.com/google/go-cmp/v0.6.0.yaml index c7b5314d92..2042ec00b7 100644 --- a/tools/licensescan/modules/github.com/google/go-cmp/v0.6.0.yaml +++ b/tools/licensescan/modules/github.com/google/go-cmp/v0.6.0.yaml @@ -1,2 +1,2 @@ # https://pkg.go.dev/github.com/google/go-cmp@v0.6.0 -license: BSD-3-Clause \ No newline at end of file +license: BSD-3-Clause diff --git a/tools/licensescan/modules/github.com/google/go-containerregistry/v0.19.1.yaml b/tools/licensescan/modules/github.com/google/go-containerregistry/v0.19.1.yaml new file mode 100644 index 0000000000..83f561acea --- /dev/null +++ b/tools/licensescan/modules/github.com/google/go-containerregistry/v0.19.1.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/google/go-containerregistry@v0.19.1 +license: Apache-2.0 diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-provider-google-beta/v1.20.0.yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-provider-google-beta/v1.20.0.yaml new file mode 100644 index 0000000000..3bb70c347d --- /dev/null +++ b/tools/licensescan/modules/github.com/hashicorp/terraform-provider-google-beta/v1.20.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/hashicorp/terraform-provider-google-beta@v1.20.0 +license: MPL-2.0 \ No newline at end of file diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-registry-address/v0.2.3.yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-registry-address/v0.2.3.yaml new file mode 100644 index 0000000000..a4e89301df --- /dev/null +++ b/tools/licensescan/modules/github.com/hashicorp/terraform-registry-address/v0.2.3.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/hashicorp/terraform-registry-address@v0.2.3 +license: MPL-2.0 \ No newline at end of file diff --git a/tools/licensescan/modules/github.com/hashicorp/terraform-svchost/v0.1.1.yaml b/tools/licensescan/modules/github.com/hashicorp/terraform-svchost/v0.1.1.yaml new file mode 100644 index 0000000000..3e5da46c52 --- /dev/null +++ b/tools/licensescan/modules/github.com/hashicorp/terraform-svchost/v0.1.1.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/hashicorp/terraform-svchost@v0.1.1 +license: MPL-2.0 diff --git a/tools/licensescan/modules/github.com/hashicorp/yamux/v0.1.1.yaml b/tools/licensescan/modules/github.com/hashicorp/yamux/v0.1.1.yaml new file mode 100644 index 0000000000..f6b2b289e3 --- /dev/null +++ b/tools/licensescan/modules/github.com/hashicorp/yamux/v0.1.1.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/hashicorp/yamux@v0.1.1 +license: MPL-2.0 \ No newline at end of file diff --git a/tools/licensescan/modules/github.com/klauspost/compress/v1.16.5.yaml b/tools/licensescan/modules/github.com/klauspost/compress/v1.16.5.yaml new file mode 100644 index 0000000000..f189287e19 --- /dev/null +++ b/tools/licensescan/modules/github.com/klauspost/compress/v1.16.5.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/klauspost/compress@v1.16.5 +license: Apache-2.0, BSD-3-Clause, MIT diff --git a/tools/licensescan/modules/github.com/moby/term/v0.0.0-20221205130635-1aeaba878587.yaml b/tools/licensescan/modules/github.com/moby/term/v0.0.0-20221205130635-1aeaba878587.yaml new file mode 100644 index 0000000000..572737ea3e --- /dev/null +++ b/tools/licensescan/modules/github.com/moby/term/v0.0.0-20221205130635-1aeaba878587.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/moby/term@v0.0.0-20221205130635-1aeaba878587 +license: Apache-2.0 diff --git a/tools/licensescan/modules/github.com/moby/term/v0.5.0.yaml b/tools/licensescan/modules/github.com/moby/term/v0.5.0.yaml new file mode 100644 index 0000000000..406ec100b5 --- /dev/null +++ b/tools/licensescan/modules/github.com/moby/term/v0.5.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/moby/term@v0.5.0 +license: Apache-2.0 \ No newline at end of file diff --git a/tools/licensescan/modules/github.com/sirupsen/logrus/v1.9.1.yaml b/tools/licensescan/modules/github.com/sirupsen/logrus/v1.9.1.yaml new file mode 100644 index 0000000000..618aec3778 --- /dev/null +++ b/tools/licensescan/modules/github.com/sirupsen/logrus/v1.9.1.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/sirupsen/logrus@v1.9.1 +license: MIT diff --git a/tools/licensescan/modules/github.com/spf13/cobra/v1.8.0.yaml b/tools/licensescan/modules/github.com/spf13/cobra/v1.8.0.yaml new file mode 100644 index 0000000000..81ada8df36 --- /dev/null +++ b/tools/licensescan/modules/github.com/spf13/cobra/v1.8.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/spf13/cobra@v1.8.0 +license: Apache-2.0 diff --git a/tools/licensescan/modules/github.com/vbatts/tar-split/v0.11.3.yaml b/tools/licensescan/modules/github.com/vbatts/tar-split/v0.11.3.yaml new file mode 100644 index 0000000000..c2cd58275e --- /dev/null +++ b/tools/licensescan/modules/github.com/vbatts/tar-split/v0.11.3.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/github.com/vbatts/tar-split@v0.11.3 +license: BSD-3-Clause \ No newline at end of file diff --git a/tools/licensescan/modules/golang.org/x/crypto/v0.21.0.yaml b/tools/licensescan/modules/golang.org/x/crypto/v0.21.0.yaml new file mode 100644 index 0000000000..0176ebeb55 --- /dev/null +++ b/tools/licensescan/modules/golang.org/x/crypto/v0.21.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/golang.org/x/crypto@v0.21.0 +license: BSD-3-Clause \ No newline at end of file diff --git a/tools/licensescan/modules/golang.org/x/mod/v0.17.0.yaml b/tools/licensescan/modules/golang.org/x/mod/v0.17.0.yaml new file mode 100644 index 0000000000..5e9e0ca2b8 --- /dev/null +++ b/tools/licensescan/modules/golang.org/x/mod/v0.17.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/golang.org/x/mod@v0.17.0 +license: BSD-3-Clause \ No newline at end of file diff --git a/tools/licensescan/modules/golang.org/x/net/v0.23.0.yaml b/tools/licensescan/modules/golang.org/x/net/v0.23.0.yaml new file mode 100644 index 0000000000..26d8528310 --- /dev/null +++ b/tools/licensescan/modules/golang.org/x/net/v0.23.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/golang.org/x/net@v0.23.0 +license: BSD-3-Clause diff --git a/tools/licensescan/modules/golang.org/x/sync/v0.2.0.yaml b/tools/licensescan/modules/golang.org/x/sync/v0.2.0.yaml new file mode 100644 index 0000000000..4e64af0d40 --- /dev/null +++ b/tools/licensescan/modules/golang.org/x/sync/v0.2.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/golang.org/x/sync@v0.2.0 +license: BSD-3-Clause \ No newline at end of file diff --git a/tools/licensescan/modules/golang.org/x/sys/v0.18.0.yaml b/tools/licensescan/modules/golang.org/x/sys/v0.18.0.yaml new file mode 100644 index 0000000000..3d19392ba3 --- /dev/null +++ b/tools/licensescan/modules/golang.org/x/sys/v0.18.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/golang.org/x/sys@v0.18.0 +license: BSD-3-Clause diff --git a/tools/licensescan/modules/golang.org/x/term/v0.18.0.yaml b/tools/licensescan/modules/golang.org/x/term/v0.18.0.yaml new file mode 100644 index 0000000000..3663669e3d --- /dev/null +++ b/tools/licensescan/modules/golang.org/x/term/v0.18.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/golang.org/x/term@v0.18.0 +license: BSD-3-Clause diff --git a/tools/licensescan/modules/google.golang.org/protobuf/v1.33.0.yaml b/tools/licensescan/modules/google.golang.org/protobuf/v1.33.0.yaml new file mode 100644 index 0000000000..3eb568cfc5 --- /dev/null +++ b/tools/licensescan/modules/google.golang.org/protobuf/v1.33.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/google.golang.org/protobuf@v1.33.0 +license: BSD-3-Clause diff --git a/tools/licensescan/modules/istio.io/api/v1.21.2.yaml b/tools/licensescan/modules/istio.io/api/v1.21.2.yaml new file mode 100644 index 0000000000..560df84121 --- /dev/null +++ b/tools/licensescan/modules/istio.io/api/v1.21.2.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/istio.io/api@v1.21.2 +license: Apache-2.0 \ No newline at end of file diff --git a/tools/licensescan/modules/k8s.io/klog/v2/v2.120.1.yaml b/tools/licensescan/modules/k8s.io/klog/v2/v2.120.1.yaml new file mode 100644 index 0000000000..34b26a57ce --- /dev/null +++ b/tools/licensescan/modules/k8s.io/klog/v2/v2.120.1.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/k8s.io/klog/v2@v2.120.1 +license: Apache-2.0 diff --git a/tools/licensescan/modules/sigs.k8s.io/yaml/v1.4.0.yaml b/tools/licensescan/modules/sigs.k8s.io/yaml/v1.4.0.yaml new file mode 100644 index 0000000000..8d96a9246f --- /dev/null +++ b/tools/licensescan/modules/sigs.k8s.io/yaml/v1.4.0.yaml @@ -0,0 +1,2 @@ +# https://pkg.go.dev/sigs.k8s.io/yaml@v1.4.0 +license: Apache-2.0, BSD-3-Clause, MIT