Skip to content

Commit 8dfc215

Browse files
check license headers script added
Signed-off-by: Michael Valdron <[email protected]>
1 parent 6802642 commit 8dfc215

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Diff for: check_licenses.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
#
3+
#
4+
# Copyright Red Hat
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
# This script checks if license headers that are missing/invalid from go files
19+
20+
if ! command -v addlicense 2> /dev/null
21+
then
22+
echo "error addlicense must be installed with this command: go install github.com/google/addlicense@latest" && exit 1
23+
else
24+
files=($(addlicense -check -v -f license_header.txt $(find . -not -path '*/\.*' -not -path '*/vendor/*' -not -name 'zz_generated.*.go' -name '*.go')))
25+
if [[ $? != 0 ]] && [[ ${#files[@]} -eq 0 ]]
26+
then
27+
echo "addheader check failed to run "
28+
exit 1
29+
elif [[ ${#files[@]} -gt 0 ]]
30+
then
31+
echo "The following files do not have valid license headers:"
32+
for file in ${files[@]}
33+
do
34+
echo ${file}
35+
done
36+
exit 1
37+
else
38+
echo "license headers are valid"
39+
fi
40+
fi

0 commit comments

Comments
 (0)