Merge pull request #114826 from liggitt/fix-license-script

Fix verify-licenses script
This commit is contained in:
Kubernetes Prow Robot 2023-01-04 23:03:59 -08:00 committed by GitHub
commit ca2f095cc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,23 +51,14 @@ packages_flagged=()
packages_url_missing=() packages_url_missing=()
exit_code=0 exit_code=0
git remote add licenses https://github.com/kubernetes/kubernetes >/dev/null 2>&1 || true
# Install go-licenses # Install go-licenses
echo '[INFO] Installing go-licenses...' echo '[INFO] Installing go-licenses...'
pushd "${KUBE_TEMP}" >/dev/null go install github.com/google/go-licenses@latest
git clone https://github.com/google/go-licenses.git >/dev/null 2>&1
cd go-licenses
go build -o "${GOPATH}/bin"
popd >/dev/null
# Fetching CNCF Approved List Of Licenses # Fetching CNCF Approved List Of Licenses
# Refer: https://github.com/cncf/foundation/blob/main/allowed-third-party-license-policy.md # Refer: https://github.com/cncf/foundation/blob/main/allowed-third-party-license-policy.md
curl -s 'https://spdx.org/licenses/licenses.json' -o "${KUBE_TEMP}"/licenses.json curl -s 'https://spdx.org/licenses/licenses.json' -o "${KUBE_TEMP}"/licenses.json
number_of_licenses=$(jq '.licenses | length' "${KUBE_TEMP}"/licenses.json) number_of_licenses=$(jq '.licenses | length' "${KUBE_TEMP}"/licenses.json)
loop_index_length=$(( number_of_licenses - 1 )) loop_index_length=$(( number_of_licenses - 1 ))
@ -85,8 +76,7 @@ done
# Scanning go-packages under the project & verifying against the CNCF approved list of licenses # Scanning go-packages under the project & verifying against the CNCF approved list of licenses
echo '[INFO] Starting license scan on go-packages...' echo '[INFO] Starting license scan on go-packages...'
go-licenses csv --git_remote licenses ./... >> "${KUBE_TEMP}"/licenses.csv 2>/dev/null go-licenses report ./... >> "${KUBE_TEMP}"/licenses.csv
echo -e 'PACKAGE_NAME LICENSE_NAME LICENSE_URL\n' >> "${KUBE_TEMP}"/approved_licenses.dump echo -e 'PACKAGE_NAME LICENSE_NAME LICENSE_URL\n' >> "${KUBE_TEMP}"/approved_licenses.dump
while IFS=, read -r GO_PACKAGE LICENSE_URL LICENSE_NAME while IFS=, read -r GO_PACKAGE LICENSE_URL LICENSE_NAME