chore: add licenses check tools (#4706)

* feat: check licenses header with skywalking-eye and support check tools.

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* feat: check licenses header with skywalking-eye and support check tools.

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* feat: check licenses header with skywalking-eye and support check tools.

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* remove verify-licenses because verify-all exist.

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* update modules.txt

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* revert go.mod

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* update vendor directory.

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* revert go.sum

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* revert go.sum

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* ignore `pkg/controller/application/status.go`

Signed-off-by: mango <xu.weiKyrie@foxmail.com>

* add license header.

Signed-off-by: mango <xu.weiKyrie@foxmail.com>
This commit is contained in:
mango
2022-03-09 10:25:13 +08:00
committed by GitHub
parent a76ba958cb
commit f018a23023
45 changed files with 719 additions and 0 deletions

46
hack/update-licenses.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# Copyright 2022 The KubeSphere 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.
#
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
if ! command -v license-eye &> /dev/null
then
# Ensure that we find the binaries we build before anything else.
export GOBIN="${KUBE_OUTPUT_BINPATH}"
PATH="${GOBIN}:${PATH}"
# Explicitly opt into go modules, even though we're inside a GOPATH directory
export GO111MODULE=on
# Explicitly clear GOFLAGS, since GOFLAGS=-mod=vendor breaks dependency resolution while rebuilding vendor
export GOFLAGS=
# Install skywalking-eyes
echo 'installing skywalking-eyes '
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
go install github.com/apache/skywalking-eyes/cmd/license-eye@v0.2.0
popd >/dev/null
fi
cd "${KUBE_ROOT}"
echo 'running skywalking-eyes fix '
license-eye header fix
exit 0

View File

@@ -28,6 +28,7 @@ EXCLUDED_PATTERNS=(
"verify-*-dockerized.sh" # Don't run any scripts that intended to be run dockerized
"verify-govet-levee.sh" # Do not run levee analysis by default while KEP-1933 implementation is in alpha.
"verify-golangci-lint.sh" # Experimental - intended to be run by hand periodically
"verify-licenses.sh"
)
while IFS='' read -r line; do EXCLUDED_CHECKS+=("$line"); done < <(ls "${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}/hack/}" 2>/dev/null || true)

46
hack/verify-licenses.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# Copyright 2022 The KubeSphere 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.
#
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
if ! command -v license-eye &> /dev/null
then
# Ensure that we find the binaries we build before anything else.
export GOBIN="${KUBE_OUTPUT_BINPATH}"
PATH="${GOBIN}:${PATH}"
# Explicitly opt into go modules, even though we're inside a GOPATH directory
export GO111MODULE=on
# Explicitly clear GOFLAGS, since GOFLAGS=-mod=vendor breaks dependency resolution while rebuilding vendor
export GOFLAGS=
# Install skywalking-eyes
echo 'installing skywalking-eyes '
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
go install github.com/apache/skywalking-eyes/cmd/license-eye@v0.2.0
popd >/dev/null
fi
cd "${KUBE_ROOT}"
echo 'running skywalking-eyes check '
license-eye header check
exit 0