From 27fe7e3b0688840de89baa9ca8e51ddfb5cf77e6 Mon Sep 17 00:00:00 2001 From: ajeet_rai <26380497+AJEETRAI707@users.noreply.github.com> Date: Tue, 8 Sep 2020 20:37:59 +0530 Subject: [PATCH] chore(check): Add license-check for .go , .sh , Dockerfile and Makefile (#205) Signed-off-by: ajeetrai707 --- .travis.yml | 1 + Makefile | 15 ++++++++++++++- buildscripts/build.sh | 13 +++++++++++++ buildscripts/test-cov.sh | 14 ++++++++++++++ buildscripts/tools.go | 3 ++- buildscripts/zfs-driver/entrypoint.sh | 13 +++++++++++++ cmd/main.go | 16 ++++++++++++++++ pkg/zfs/mount.go | 15 +++++++++++++++ upgrade/cleanup.sh | 13 +++++++++++++ upgrade/upgrade.sh | 14 ++++++++++++++ 10 files changed, 115 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index abd5d15..793bd12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ install: fi - make bootstrap - make format + - make license-check - make golint - curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ diff --git a/Makefile b/Makefile index 47065d0..2332bb6 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ export DBUILD_ARGS=--build-arg DBUILD_DATE=${DBUILD_DATE} --build-arg DBUILD_REP CSI_DRIVER=zfs-driver .PHONY: all -all: test manifests zfs-driver-image +all: license-check test manifests zfs-driver-image .PHONY: clean clean: @@ -246,3 +246,16 @@ golint: @echo "Completed golint no recommendations !!" @echo "--------------------------------" @echo "" + +.PHONY: license-check +license-check: + @echo "--> Checking license header..." + @licRes=$$(for file in $$(find . -type f -regex '.*\.sh\|.*\.go\|.*Docker.*\|.*\Makefile*' ! -path './vendor/*' ) ; do \ + awk 'NR<=5' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \ + done); \ + if [ -n "$${licRes}" ]; then \ + echo "license header checking failed:"; echo "$${licRes}"; \ + exit 1; \ + fi + @echo "--> Done checking license." + @echo diff --git a/buildscripts/build.sh b/buildscripts/build.sh index 1e66cb6..8037795 100755 --- a/buildscripts/build.sh +++ b/buildscripts/build.sh @@ -1,5 +1,18 @@ #!/usr/bin/env bash + +# Copyright © 2020 The OpenEBS 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. + # This script builds the application from source for multiple platforms. set -e diff --git a/buildscripts/test-cov.sh b/buildscripts/test-cov.sh index a68f52f..be9c8fa 100755 --- a/buildscripts/test-cov.sh +++ b/buildscripts/test-cov.sh @@ -1,3 +1,17 @@ +# Copyright © 2020 The OpenEBS 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. + #!/usr/bin/env bash set -e diff --git a/buildscripts/tools.go b/buildscripts/tools.go index e65e645..69f26f2 100644 --- a/buildscripts/tools.go +++ b/buildscripts/tools.go @@ -1,6 +1,7 @@ // +build tools /* +Copyright 2019 The Kubernetes Authors. copyright 2020 the kubernetes authors. licensed under the apache license, version 2.0 (the "license"); @@ -16,7 +17,7 @@ see the license for the specific language governing permissions and limitations under the license. */ -// this package imports things required by build scripts, to force `go mod` to see them as dependencies +// tools package imports things required by build scripts, to force `go mod` to see them as dependencies package tools import _ "k8s.io/code-generator" diff --git a/buildscripts/zfs-driver/entrypoint.sh b/buildscripts/zfs-driver/entrypoint.sh index a24b20d..6489015 100644 --- a/buildscripts/zfs-driver/entrypoint.sh +++ b/buildscripts/zfs-driver/entrypoint.sh @@ -1,3 +1,16 @@ +# Copyright © 2020 The OpenEBS 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. + #!/bin/sh set -ex diff --git a/cmd/main.go b/cmd/main.go index 3e3b976..feece4c 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,3 +1,19 @@ +/* +Copyright © 2020 The OpenEBS 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 main import ( diff --git a/pkg/zfs/mount.go b/pkg/zfs/mount.go index 5899cd3..633924a 100644 --- a/pkg/zfs/mount.go +++ b/pkg/zfs/mount.go @@ -1,3 +1,18 @@ +/* +Copyright © 2020 The OpenEBS 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 zfs import ( diff --git a/upgrade/cleanup.sh b/upgrade/cleanup.sh index 3f94a06..d69abce 100644 --- a/upgrade/cleanup.sh +++ b/upgrade/cleanup.sh @@ -1,3 +1,16 @@ +# Copyright © 2020 The OpenEBS 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. #!/bin/bash set -e diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index b6b2e94..e9c18ad 100644 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -1,3 +1,17 @@ +# Copyright © 2020 The OpenEBS 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. + #!/bin/bash # do not provision/deprovision anything while running the upgrade script.