Skip to content

Commit 5c3b976

Browse files
authored
[Backport 7.13] License header checker (#264)
* Github Action: Add license checker for pull requests * Generator: Update license header * Client: Update license header * Godoc: Add license header
1 parent 05db792 commit 5c3b976

File tree

493 files changed

+7972
-1457
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

493 files changed

+7972
-1457
lines changed

.github/check-license-headers.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
# Licensed to Elasticsearch B.V. under one or more agreements.
4+
# Elasticsearch B.V. licenses this file to you under the Apache 2.0 License.
5+
# See the LICENSE file in the project root for more information.
6+
7+
# Check that source code files in this repo have the appropriate license
8+
# header.
9+
10+
if [ "$TRACE" != "" ]; then
11+
export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
12+
set -o xtrace
13+
fi
14+
set -o errexit
15+
set -o pipefail
16+
17+
TOP=$(cd "$(dirname "$0")/.." >/dev/null && pwd)
18+
NLINES=$(wc -l .github/license-header.txt | awk '{print $1}')
19+
20+
function check_license_header {
21+
local f
22+
f=$1
23+
if ! diff .github/license-header.txt <(head -$NLINES "$f") >/dev/null; then
24+
echo "check-license-headers: error: '$f' does not have required license header, see 'diff -u .github/license-header.txt <(head -$NLINES $f)'"
25+
return 1
26+
else
27+
return 0
28+
fi
29+
}
30+
31+
32+
cd "$TOP"
33+
nErrors=0
34+
for f in $(git ls-files | grep '\.go$'); do
35+
if ! check_license_header $f; then
36+
nErrors=$((nErrors+1))
37+
fi
38+
done
39+
40+
if [[ $nErrors -eq 0 ]]; then
41+
exit 0
42+
else
43+
exit 1
44+
fi

.github/license-header.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// 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,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.

.github/workflows/license.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: License headers
2+
3+
on: [ pull_request ]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Check license headers
14+
run: |
15+
./.github/check-license-headers.sh

_examples/bulk/benchmarks/benchmarks.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
// Licensed to Elasticsearch B.V. under one or more agreements.
2-
// Elasticsearch B.V. licenses this file to you under the Apache 2.0 License.
3-
// See the LICENSE file in the project root for more information.
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// 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,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
417

518
// +build ignore
619

_examples/bulk/benchmarks/model/model.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
// Licensed to Elasticsearch B.V. under one or more agreements.
2-
// Elasticsearch B.V. licenses this file to you under the Apache 2.0 License.
3-
// See the LICENSE file in the project root for more information.
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// 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,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
417

518
//go:generate easyjson $GOFILE
619

_examples/bulk/benchmarks/runner/runner.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
// Licensed to Elasticsearch B.V. under one or more agreements.
2-
// Elasticsearch B.V. licenses this file to you under the Apache 2.0 License.
3-
// See the LICENSE file in the project root for more information.
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// 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,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
417

518
package runner
619

_examples/bulk/default.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
// Licensed to Elasticsearch B.V. under one or more agreements.
2-
// Elasticsearch B.V. licenses this file to you under the Apache 2.0 License.
3-
// See the LICENSE file in the project root for more information.
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// 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,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
417

518
// +build ignore
619

_examples/bulk/indexer.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
// Licensed to Elasticsearch B.V. under one or more agreements.
2-
// Elasticsearch B.V. licenses this file to you under the Apache 2.0 License.
3-
// See the LICENSE file in the project root for more information.
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// 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,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
417

518
// +build ignore
619

_examples/bulk/kafka/consumer/consumer.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
// Licensed to Elasticsearch B.V. under one or more agreements.
2-
// Elasticsearch B.V. licenses this file to you under the Apache 2.0 License.
3-
// See the LICENSE file in the project root for more information.
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// 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,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
417

518
package consumer
619

_examples/bulk/kafka/kafka.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
// Licensed to Elasticsearch B.V. under one or more agreements.
2-
// Elasticsearch B.V. licenses this file to you under the Apache 2.0 License.
3-
// See the LICENSE file in the project root for more information.
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// 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,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
417

518
// +build ignore
619

0 commit comments

Comments
 (0)