Skip to content

Commit 0a104b3

Browse files
committed
Add check-license target
1 parent 9db1e01 commit 0a104b3

File tree

5 files changed

+77
-1
lines changed

5 files changed

+77
-1
lines changed

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,23 @@ test: ## Run unit tests
2323
vet: ## Run go vet
2424
@go vet $(addprefix ./, $(SOURCE_DIRS))
2525

26-
check: fmtcheck vet lint build test ## Pre-flight checks before creating PR
26+
tidy: ## Tidy go dependencies
27+
@go mod tidy
28+
29+
check-license: $(SOURCES)
30+
@./hack/check-license.sh "$(SOURCES)"
31+
32+
fake:
33+
# for f in $^ ; do \
34+
# if ! head -n3 "$${f}" | grep -Eq "(Copyright|generated|GENERATED|Licensed)" ; then \
35+
# licRes="$${licRes}\n"$(echo -e " $${f}") \
36+
# fi \
37+
# done
38+
@#echo $(SOURCES)
39+
@#@for f in $(SOURCES); do echo $$(f); done
40+
41+
check: tidy fmtcheck vet lint build test check-license ## Pre-flight checks before creating PR
42+
@git diff --exit-code
2743

2844
clean: ## Clean up your working environment
2945
@rm -f coverage-all.out coverage.out

hack/check-license.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
echo "Checking for license header..."
8+
allfiles=$1
9+
licRes=""
10+
for file in $allfiles; do
11+
if ! head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED|Licensed)" ; then
12+
licRes="${licRes}\n"$(echo -e " ${file}")
13+
fi
14+
done
15+
if [ -n "${licRes}" ]; then
16+
echo -e "license header checking failed:\n${licRes}"
17+
exit 255
18+
fi

leader/leader_suite_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2018 The Operator-SDK Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package leader
216

317
import (

leader/leader_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2018 The Operator-SDK Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package leader
216

317
import (

predicate/dependent_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2018 The Operator-SDK Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package predicate
216

317
import (

0 commit comments

Comments
 (0)