diff --git a/Makefile b/Makefile index 8d57873..d928f80 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,14 @@ test: ## Run unit tests vet: ## Run go vet @go vet $(addprefix ./, $(SOURCE_DIRS)) -check: fmtcheck vet lint build test ## Pre-flight checks before creating PR +tidy: ## Tidy go dependencies + @go mod tidy + +check-license: $(SOURCES) + @./hack/check-license.sh "$(SOURCES)" + +check: tidy fmtcheck vet lint build test check-license ## Pre-flight checks before creating PR + @git diff --exit-code clean: ## Clean up your working environment @rm -f coverage-all.out coverage.out diff --git a/hack/check-license.sh b/hack/check-license.sh new file mode 100755 index 0000000..2d200d3 --- /dev/null +++ b/hack/check-license.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +echo "Checking for license header..." +allfiles=$1 +licRes="" +for file in $allfiles; do + if ! head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED|Licensed)" ; then + licRes="${licRes}\n"$(echo -e " ${file}") + fi +done +if [ -n "${licRes}" ]; then + echo -e "license header checking failed:\n${licRes}" + exit 255 +fi diff --git a/handler/enqueue_annotation.go b/handler/enqueue_annotation.go index d6b1fa4..db8020a 100644 --- a/handler/enqueue_annotation.go +++ b/handler/enqueue_annotation.go @@ -1,4 +1,4 @@ -// Copyright 2019 The Operator-SDK Authors +// Copyright 2020 The Operator-SDK Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/leader/doc.go b/leader/doc.go index b88c30a..3eee3e3 100644 --- a/leader/doc.go +++ b/leader/doc.go @@ -1,4 +1,4 @@ -// Copyright 2018 The Operator-SDK Authors +// Copyright 2020 The Operator-SDK Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/leader/leader.go b/leader/leader.go index 55f3778..89e9c86 100644 --- a/leader/leader.go +++ b/leader/leader.go @@ -1,4 +1,4 @@ -// Copyright 2018 The Operator-SDK Authors +// Copyright 2020 The Operator-SDK Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/leader/leader_suite_test.go b/leader/leader_suite_test.go index 9c23d3c..5fc7ed5 100644 --- a/leader/leader_suite_test.go +++ b/leader/leader_suite_test.go @@ -1,3 +1,17 @@ +// Copyright 2020 The Operator-SDK Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package leader import ( diff --git a/leader/leader_test.go b/leader/leader_test.go index acf85b4..1c991d2 100644 --- a/leader/leader_test.go +++ b/leader/leader_test.go @@ -1,3 +1,17 @@ +// Copyright 2020 The Operator-SDK Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package leader import ( diff --git a/predicate/dependent.go b/predicate/dependent.go index 28b4dfe..22cd574 100644 --- a/predicate/dependent.go +++ b/predicate/dependent.go @@ -1,4 +1,4 @@ -// Copyright 2019 The Operator-SDK Authors +// Copyright 2020 The Operator-SDK Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/predicate/dependent_test.go b/predicate/dependent_test.go index b61bbea..ddec43c 100644 --- a/predicate/dependent_test.go +++ b/predicate/dependent_test.go @@ -1,3 +1,17 @@ +// Copyright 2018 The Operator-SDK Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package predicate import (