Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce SPDX headers in Go files with goheader linter #1388

Merged
merged 3 commits into from
Aug 28, 2023

Conversation

lambdanis
Copy link
Contributor

@lambdanis lambdanis commented Aug 25, 2023

The first two commits update many Go files to use the SPDX header consistently. See commit messages for how it was done.

The last commit adds goheader linter to .golangci-lint to enforce these headers.

Let me know if something should look differently. I found missing headers in some PRs recently, so decided to automate this check instead of being a robot.

@lambdanis lambdanis requested a review from a team as a code owner August 25, 2023 16:12
@netlify
Copy link

netlify bot commented Aug 25, 2023

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit d76e342
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/64e8d2e33701510008be547e
😎 Deploy Preview https://deploy-preview-1388--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@lambdanis lambdanis marked this pull request as draft August 25, 2023 16:14
This commit changes Apache-2 license headers to use SPDX. It was achieved with
a regex replace in VSCode:

```
// Copyright \d{4}(-\d{4})? Authors of (Cilium|Hubble|Tetragon)
//
// 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.
```
replaced by
```
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of $2
```

followed by:
```
$ make codegen
$ make generate
```

Signed-off-by: Anna Kapuscinska <[email protected]>
This commit adds an SPDX license header to Go files that didn't have it. It was
achieved with a regex replace in VSCode:

```
^(?<![\s\S\r])((?!// SPDX-License-Identifier: Apache-2.0))
```
replaced by
```
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Tetragon

```

followed by:
```
$ make codegen
$ make generate
```

Signed-off-by: Anna Kapuscinska <[email protected]>
This will enforce that all Go files start with
```
SPDX-License-Identifier: Apache-2.0
Copyright Authors of Tetragon|Cilium|Hubble
```

Signed-off-by: Anna Kapuscinska <[email protected]>
@lambdanis lambdanis marked this pull request as ready for review August 25, 2023 18:41
@lambdanis lambdanis merged commit 0c4394b into main Aug 28, 2023
25 checks passed
@lambdanis lambdanis deleted the pr/lambdanis/spdx-linter branch August 28, 2023 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants