Skip to content

Commit e9904a2

Browse files
stuartnelson3jlvoiseuxsimitt
authored
Generate NOTICE.txt and dependencies.asciidoc (#207)
Co-authored-by: Jean-Louis Voiseux <48380853+jlvoiseux@users.noreply.github.com> Co-authored-by: Silvia Mitter <silvia.mitter@elastic.co>
1 parent 11fdbbe commit e9904a2

File tree

11 files changed

+1456
-18
lines changed

11 files changed

+1456
-18
lines changed

.ci/Jenkinsfile

+10
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ pipeline {
5151
}
5252
}
5353
}
54+
withGithubNotify(context: "NOTICE.txt") {
55+
dir("${BASE_DIR}"){
56+
withGoEnv(){
57+
sh(label: 'notice', script: '''
58+
bash ./apm-lambda-extension/scripts/notice.sh
59+
git diff --exit-code --quiet && exit 0 || echo "regenerate NOTICE.txt" && exit 1
60+
''')
61+
}
62+
}
63+
}
5464
}
5565
}
5666
stage('Test') {
File renamed without changes.

apm-lambda-extension/Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export AWS_FOLDER GOARCH ARCHITECTURE DOCKER_IMAGE_NAME DOCKER_REGISTRY
2121
.PHONY: all
2222
all: build
2323

24+
.PHONY: gen-notice
25+
gen-notice:
26+
@bash ./scripts/notice.sh
27+
2428
check-licenses:
2529
go install github.com/elastic/go-licenser@v0.4.0
2630
go run github.com/elastic/go-licenser@v0.4.0 -d .
@@ -37,7 +41,7 @@ lint:
3741
golangci-lint --version
3842
golangci-lint run
3943

40-
build: check-licenses
44+
build: check-licenses gen-notice
4145
GOOS=linux go build -o bin/extensions/apm-lambda-extension main.go
4246
chmod +x bin/extensions/apm-lambda-extension
4347
build-and-publish: check-licenses validate-layer-name validate-aws-default-region

apm-lambda-extension/NOTICE

-17
This file was deleted.

apm-lambda-extension/NOTICE.txt

+1,256
Large diffs are not rendered by default.
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Generated documentation. Please do not edit.
2+
:page_id: dependencies
3+
4+
[id="{p}-{page_id}"]
5+
= Third-party dependencies
6+
7+
This page lists the third-party dependencies used to build {n}.
8+
9+
[float]
10+
[id="{p}-dependencies-direct"]
11+
== Direct dependencies
12+
13+
[options="header"]
14+
|===
15+
| Name | Version | Licence
16+
17+
| link:https://github.com/google/uuid[$$github.com/google/uuid$$] | v1.3.0 | BSD-3-Clause
18+
| link:https://github.com/joho/godotenv[$$github.com/joho/godotenv$$] | v1.4.0 | MIT
19+
| link:https://github.com/pkg/errors[$$github.com/pkg/errors$$] | v0.9.1 | BSD-2-Clause
20+
| link:https://github.com/stretchr/testify[$$github.com/stretchr/testify$$] | v1.7.0 | MIT
21+
| link:https://go.elastic.co/ecszap[$$go.elastic.co/ecszap$$] | v1.0.1 | Apache-2.0
22+
| link:https://go.uber.org/zap[$$go.uber.org/zap$$] | v1.21.0 | MIT
23+
| link:https://gotest.tools[$$gotest.tools$$] | v2.2.0+incompatible | Apache-2.0
24+
|===
25+
26+
27+
[float]
28+
[id="{p}-dependencies-indirect"]
29+
== Indirect dependencies
30+
31+
[options="header"]
32+
|===
33+
| Name | Version | Licence
34+
35+
| link:https://github.com/benbjohnson/clock[$$github.com/benbjohnson/clock$$] | v1.1.0 | MIT
36+
| link:https://github.com/davecgh/go-spew[$$github.com/davecgh/go-spew$$] | v1.1.1 | ISC
37+
| link:https://github.com/google/go-cmp[$$github.com/google/go-cmp$$] | v0.5.6 | BSD-3-Clause
38+
| link:https://github.com/kr/pretty[$$github.com/kr/pretty$$] | v0.1.0 | MIT
39+
| link:https://github.com/kr/text[$$github.com/kr/text$$] | v0.1.0 | MIT
40+
| link:https://github.com/magefile/mage[$$github.com/magefile/mage$$] | v1.13.0 | Apache-2.0
41+
| link:https://github.com/pmezard/go-difflib[$$github.com/pmezard/go-difflib$$] | v1.0.0 | BSD-3-Clause
42+
| link:https://go.uber.org/atomic[$$go.uber.org/atomic$$] | v1.9.0 | MIT
43+
| link:https://go.uber.org/goleak[$$go.uber.org/goleak$$] | v1.1.11 | MIT
44+
| link:https://go.uber.org/multierr[$$go.uber.org/multierr$$] | v1.8.0 | MIT
45+
| link:https://golang.org/x/xerrors[$$golang.org/x/xerrors$$] | v0.0.0-20200804184101-5ec99f83aff1 | BSD-3-Clause
46+
| link:https://gopkg.in/check.v1[$$gopkg.in/check.v1$$] | v1.0.0-20180628173108-788fd7840127 | BSD-2-Clause
47+
| link:https://gopkg.in/yaml.v2[$$gopkg.in/yaml.v2$$] | v2.2.8 | Apache-2.0
48+
| link:https://gopkg.in/yaml.v3[$$gopkg.in/yaml.v3$$] | v3.0.0-20210107192922-496545a6307b | MIT
49+
|===
50+
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2022 Elasticsearch BV
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Script to generate a NOTICE file containing licence information from dependencies.
18+
19+
# cf. https://github.com/elastic/cloud-on-k8s/tree/main/hack/licence-detector
20+
21+
set -euo pipefail
22+
23+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
24+
PROJECT_DIR=${SCRIPT_DIR}/..
25+
TEMP_DIR=$(mktemp -d)
26+
LICENCE_DETECTOR="go.elastic.co/go-licence-detector@v0.3.0"
27+
28+
trap '[[ $TEMP_DIR ]] && rm -rf "$TEMP_DIR"' EXIT
29+
30+
get_licence_detector() {
31+
GOBIN="$TEMP_DIR" go install "$LICENCE_DETECTOR"
32+
}
33+
34+
generate_notice() {
35+
(
36+
cd "$PROJECT_DIR"
37+
go mod download
38+
go list -m -json all | "${TEMP_DIR}"/go-licence-detector \
39+
-depsTemplate="${SCRIPT_DIR}"/templates/dependencies.asciidoc.tmpl \
40+
-depsOut="${PROJECT_DIR}"/dependencies.asciidoc \
41+
-noticeTemplate="${SCRIPT_DIR}"/templates/NOTICE.txt.tmpl \
42+
-noticeOut="${PROJECT_DIR}"/NOTICE.txt \
43+
-overrides="${SCRIPT_DIR}"/overrides/overrides.json \
44+
-rules="${SCRIPT_DIR}"/rules.json \
45+
-includeIndirect
46+
)
47+
}
48+
49+
echo "Generating notice file and dependency list"
50+
get_licence_detector
51+
generate_notice

apm-lambda-extension/scripts/overrides/overrides.json

Whitespace-only changes.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"allowlist": [
3+
"Apache-2.0",
4+
"BSD-2-Clause",
5+
"BSD-2-Clause-FreeBSD",
6+
"BSD-3-Clause",
7+
"ISC",
8+
"MIT",
9+
"MPL-2.0",
10+
"Public Domain"
11+
]
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- define "depInfo" -}}
2+
{{- range $i, $dep := . }}
3+
{{ "-" | line }}
4+
Module : {{ $dep.Name }}
5+
Version : {{ $dep.Version }}
6+
Time : {{ $dep.VersionTime }}
7+
Licence : {{ $dep.LicenceType }}
8+
9+
{{ $dep | licenceText }}
10+
{{ end }}
11+
{{- end -}}
12+
13+
Copyright {{ currentYear }} Elasticsearch BV
14+
15+
Licensed under the Apache License, Version 2.0 (the "License");
16+
you may not use this file except in compliance with the License.
17+
You may obtain a copy of the License at
18+
19+
http://www.apache.org/licenses/LICENSE-2.0
20+
21+
Unless required by applicable law or agreed to in writing, software
22+
distributed under the License is distributed on an "AS IS" BASIS,
23+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24+
See the License for the specific language governing permissions and
25+
limitations under the License.
26+
27+
{{ "=" | line }}
28+
Third party libraries used by the Elastic APM AWS Lambda extension.
29+
{{ "=" | line }}
30+
31+
{{ template "depInfo" .Direct }}
32+
33+
{{ if .Indirect }}
34+
{{ "=" | line }}
35+
Indirect dependencies
36+
37+
{{ template "depInfo" .Indirect }}
38+
{{ end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{- define "depRow" -}}
2+
{{- range $i, $dep := . }}
3+
| link:{{ $dep.URL }}[$${{ $dep.Name }}$$] | {{ $dep.Version }} | {{ $dep.LicenceType }}
4+
{{- end }}
5+
{{- end -}}
6+
// Generated documentation. Please do not edit.
7+
:page_id: dependencies
8+
9+
[id="{p}-{page_id}"]
10+
= Third-party dependencies
11+
12+
This page lists the third-party dependencies used to build {n}.
13+
14+
[float]
15+
[id="{p}-dependencies-direct"]
16+
== Direct dependencies
17+
18+
[options="header"]
19+
|===
20+
| Name | Version | Licence
21+
{{ template "depRow" .Direct }}
22+
|===
23+
24+
{{ if .Indirect }}
25+
[float]
26+
[id="{p}-dependencies-indirect"]
27+
== Indirect dependencies
28+
29+
[options="header"]
30+
|===
31+
| Name | Version | Licence
32+
{{ template "depRow" .Indirect }}
33+
|===
34+
{{ end }}

0 commit comments

Comments
 (0)