forked from shipwright-io/build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate and verify copyright in source files (shipwright-io#369)
* Add script to generate copyright Per guidance from Red Hat's Open Source Program Office (OSPO), all source files should have the following copyright notice: ``` Copyright The Shipwright Contributors SPDX-License-Identifier: Apache-2.0 ``` The SPDX-License-Identifier is a stand-in for the standard Apache 2.0 boilerplate notice, with the added benefit that this can be easily identified by license parsers [1]. Dropping the date in the copyright notice is likewise acceptable, per the Linux Foundation's latest guidance [2]. The generator script creates copyright for golang, shell, Markdown, and Dockerfiles. A Makefile target has also been added. [1] https://spdx.dev/ids/ [2] https://www.linuxfoundation.org/blog/2020/01/copyright-notices-in-open-source-software-projects/ * make gen-copyright * Verify copyright Added Makefile target that verifies copyright is applied to all files we track. Updated Travis to verify copyright on all PRs. Note - the following files are excluded from the copyright verifier: - go.mod and go.sum - vendor/*
- Loading branch information
1 parent
051b652
commit ce34d83
Showing
93 changed files
with
523 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
<!-- | ||
Copyright The Shipwright Contributors | ||
SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
|
||
# Running the Operator | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
// Copyright The Shipwright Contributors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright The Shipwright Contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -e | ||
|
||
copyrightTxt="Copyright The Shipwright Contributors" | ||
spdxTxt="SPDX-License-Identifier: Apache-2.0" | ||
|
||
function listPkgDirs() { | ||
go list -f '{{.Dir}}' ./cmd/... ./pkg/... ./test/... ./version/... | ||
local goFiles=$? | ||
} | ||
|
||
function listGoFiles() { | ||
# pipeline is much faster than for loop | ||
listPkgDirs | xargs -I {} find {} -name '*.go' | ||
local goFiles=$? | ||
echo $PWD/tools.go | ||
goFiles="$goFiles $?" | ||
} | ||
|
||
function listDockerfiles() { | ||
find -name 'Dockerfile*' -not -path './vendor/*' | ||
} | ||
|
||
function listBashFiles() { | ||
find -name '*.sh' -not -path './vendor/*' | ||
local bashFiles=$? | ||
find ./build/bin -type f | ||
bashFiles="$bashFiles $?" | ||
} | ||
|
||
function listMarkdownFiles() { | ||
find -name '*.md' -not -path './vendor/*' | ||
} | ||
|
||
function generateGoCopyright() { | ||
allFiles=$(listGoFiles) | ||
|
||
for file in $allFiles ; do | ||
if ! head -n3 "${file}" | grep -Eq "(Copyright|SPDX-License-Identifier)" ; then | ||
cp "${file}" "${file}.bak" | ||
echo "// ${copyrightTxt}" > "${file}" | ||
echo "// " >> "${file}" | ||
echo "// ${spdxTxt}" >> "${file}" | ||
echo "" >> "${file}" | ||
cat "${file}.bak" >> "${file}" | ||
rm "${file}.bak" | ||
fi | ||
done | ||
} | ||
|
||
function generateDockerfileCopyright() { | ||
dockerfiles=$(listDockerfiles) | ||
for file in $dockerfiles ; do | ||
if ! head -n3 "${file}" | grep -Eq "(Copyright|SPDX-License-Identifier)" ; then | ||
cp "${file}" "${file}.bak" | ||
echo "# ${copyrightTxt}" > "${file}" | ||
echo "# " >> "${file}" | ||
echo "# ${spdxTxt}" >> "${file}" | ||
echo "" >> "${file}" | ||
cat "${file}.bak" >> "${file}" | ||
rm "${file}.bak" | ||
fi | ||
done | ||
} | ||
|
||
function generateBashCopyright() { | ||
bashFiles=$(listBashFiles) | ||
for file in $bashFiles ; do | ||
if ! head -n5 "${file}" | grep -Eq "(Copyright|SPDX-License-Identifier)" ; then | ||
cp "${file}" "${file}.bak" | ||
# Copy the shebang first - this is assumed to be the first line | ||
head -n1 "${file}.bak" > "${file}" | ||
echo "" >> "${file}" | ||
echo "# ${copyrightTxt}" >> "${file}" | ||
echo "# " >> "${file}" | ||
echo "# ${spdxTxt}" >> "${file}" | ||
echo "" >> "${file}" | ||
tail -n +2 "${file}.bak" >> "${file}" | ||
rm "${file}.bak" | ||
fi | ||
done | ||
} | ||
|
||
function generateMarkdownCopyright() { | ||
mdFiles=$(listMarkdownFiles) | ||
for file in $mdFiles ; do | ||
if ! head -n4 "${file}" | grep -Eq "(Copyright|SPDX-License-Identifier)" ; then | ||
cp "${file}" "${file}.bak" | ||
echo "<!--" > "${file}" | ||
echo "${copyrightTxt}" >> "${file}" | ||
echo "" >> "${file}" | ||
echo "${spdxTxt}" >> "${file}" | ||
echo "-->" >> "${file}" | ||
echo "" >> "${file}" | ||
cat "${file}.bak" >> "${file}" | ||
rm "${file}.bak" | ||
fi | ||
done | ||
} | ||
|
||
generateGoCopyright | ||
generateDockerfileCopyright | ||
generateBashCopyright | ||
generateMarkdownCopyright | ||
|
||
set +e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.